Which one or more of the following need to be saved on a context switch from one thread of a process to another thread of the same process?
GATE CSE 2023Operating System › Process Concepts, Threads & System CallsVerified
GATE CSE 2023 PYQ: Which one or more of the following need to be saved on a context switch from one thread (T1) \text{(T1)}…
- APage table base register
- BStack pointerCorrect answer
- CProgram counterCorrect answer
- DGeneral purpose registersCorrect answer
Answer
(B, C, D) Stack pointer; Program counter; General purpose registers
Approach
Identify which CPU/process state is per-thread versus per-process. Threads in the same process share the address space, but each thread has its own execution context: PC, stack pointer, and register values.
Threads of the same process share the page table/address space, so the page table base register does not change. However, each thread has independent stack pointer, program counter, and general-purpose registers, so B, C, and D must be saved on a context switch.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.