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?
View worked solution
Answer: B;C;D
To determine what needs to be saved during a context switch between two threads of the same process, we must distinguish between resources shared among threads of a process and resources that are private to each thread.
- Shared Resources (Process-level): All threads of a process share the same address space, code section, data section, and operating system resources (like open files). Since the address space is shared, the Page Table Base Register (PTBR) remains identical. Thus, the PTBR does not need to be saved or changed during an intra-process thread context switch.
- Private Resources (Thread-level): Each thread has its own independent path of execution. Therefore, each thread must maintain its own:
- Program Counter (PC): To track which instruction to execute next.
- Stack Pointer (SP): To manage its own local variables and function call stack.
- General Purpose Registers (GPRs): To hold temporary execution data and state.
During a context switch from thread to thread of the same process, the CPU registers (including the PC, SP, and GPRs) of must be saved into its Thread Control Block (TCB), and those of must be restored.
Hence, the correct options are B, C, and D.
Free practice · Your answers on this page are not saved.
