GATE / CS ARCHIVE

GATE CSE 2023 / QUESTION 22

GATE CSE 2023 Q22

Operating Systems · Processes, Threads & System Calls · Full GATE CSE 2023 paper

GATE 2023, Q22 1 mark · MSQ
Report issue

Processes, Threads & System Calls

Question 22, GATE 2023: During a switch between two threads of the same process, which state needs saving? A page-table base register; B stack pointer; C program counter; D general-purpose registers. Select all applicable options.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C, D

Threads in one process share the same virtual address space, so the page-table base normally need not change. Their stacks, instruction positions, and working register values differ, requiring preservation of stack pointer, program counter, and general-purpose registers. Thus B, C, D in the usual same-process thread model.

Teaching detail. A thread must later resume at its own instruction and restore the register values on which that computation depends. It also needs its own stack pointer because function frames and local storage belong to that thread's call chain. Threads in one process ordinarily share the page tables, so changing only the thread does not require switching the address-space root. Real implementations may save additional architecture-specific state, but that does not alter which of the four listed items are logically thread-specific in the stated model.

Original paper, page 20 · Answer key