Skip to content
Official PYQ · 2023

GATE CS 2023 Q12 — Processes and Threads

Explain with AI

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

Select all correct options
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 T1T_1 to thread T2T_2 of the same process, the CPU registers (including the PC, SP, and GPRs) of T1T_1 must be saved into its Thread Control Block (TCB), and those of T2T_2 must be restored.

Hence, the correct options are B, C, and D.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Processes and Threads questions