Question:medium

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

Show Hint

In thread context switching, save only the thread-specific CPU state (SP, PC, registers).
In process context switching, save both CPU state and memory-related state (page tables, segment tables).
Updated On: Feb 3, 2026
  • Page table base register
  • Stack pointer
  • Program counter
  • General purpose registers
Show Solution

The Correct Option is B

Solution and Explanation

In the context of a context switch between threads of the same process, certain information must be preserved to ensure that execution can resume correctly. Here, we are examining what needs to be saved when switching from one thread (T1) to another thread (T2) of the same process.

Let's assess each option:

  • Page table base register: This register is used to store the base address of the page table in memory. It is associated with processes, not threads, because threads within the same process share the same memory space, including the page table. Therefore, this does not need to be saved during a thread switch.
  • Stack pointer: The stack pointer is used to manage the stack, which tracks function calls and local variables. Each thread has its own stack, hence its own stack pointer. During a context switch, the current stack pointer of T1 must be saved so that it can be restored when T1 resumes, while the stack pointer for T2 must be loaded to resume T2's execution.
  • Program counter: This register indicates the next instruction to be executed. Like the stack pointer, each thread has its own program counter, and it must be saved and restored during a context switch between threads to ensure execution picks up correctly.
  • General purpose registers: These registers store temporary data the CPU needs while executing instructions. Since each thread can operate on different parts of the process data, these registers need to be saved and restored to maintain the execution state of each thread correctly.

From this analysis:

  1. The Stack pointer is one of the vital components that need to be saved and restored during a context switch due to each thread having its own stack.
  2. Although other components like the program counter and general-purpose registers are also crucial for a complete context switch, the primary focus here according to the correct answer provided is on the Stack pointer.

Thus, the correct answer is the Stack pointer.

Was this answer helpful?
0