Question
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?
Official answer and solution
- Official answer
- B, C and D
- From
- Official GATE 2023 answer key
Solution
Distinguish between process-wide shared resources and per-thread private execution contexts.
Threads belonging to the same process share the process address space, including code, global data, open file descriptors, and the page table. Therefore, the Page Table Base Register (PTBR) is NOT modified during a thread context switch within the same process.
However, each thread possesses its own independent execution context:
- Stack Pointer (SP): each thread has its own private call stack.
- Program Counter (PC): each thread tracks its own instruction execution stream.
- General Purpose Registers: hold intermediate values private to the running thread.
Thus, the Stack pointer, Program counter, and General purpose registers must all be saved.
Options (B, C, D)
Selecting Page table base register, which is only switched during a full process context switch, not an intra-process thread switch.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2023 Computer Science and Information Technology (CS)
- Question
- 22 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.