Redirected
edited by
9,915 views
8 votes
8 votes

Which one or more of the following need to be saved on a context switch from one thread $\text{(T1)}$ of a process to another thread $\text{(T2)}$ of the same process?

  1. Page table base register
  2. Stack pointer
  3. Program counter
  4. General purpose registers
edited by

1 Answer

12 votes
12 votes

Answer: B, C, D

Page table base register: This register holds the base address of the page table for the currently executing thread. Since all the threads of a process share the same page table, this register needs needs not be saved.

Stack pointer: This register points to the top of the stack for the currently executing thread. Since each thread has its own stack, the stack pointer needs to be saved and restored on a context switch to ensure that the new thread uses the correct stack.

Program counter: This register contains the address of the next instruction to be executed by the currently executing thread. To resume execution of the new thread, the saved program counter needs to be loaded into the program counter register.

General purpose registers: These registers are used to store temporary data and intermediate results during the execution of a thread. Since the state of these registers can be different for each thread, they need to be saved and restored on a context switch.

So, the Stack pointer, Program counter, and General purpose registers must be saved before a context switch between threads (or between processes) to ensure correct execution of the program.

Answer:

Related questions

12 votes
12 votes
4 answers
1
admin asked Feb 15, 2023
11,452 views
Which one or more of the following options guarantee that a computer system will transition from user mode to kernel mode?Function Callmalloc CallPage FaultSystem Call
21 votes
21 votes
5 answers
2
admin asked Feb 15, 2023
14,557 views
Which one or more of the following $\text{CPU}$ scheduling algorithms can potentially cause starvation?First-in First-OutRound RobinPriority SchedulingShortest Job First