Question
Which of the following is/are shared by all the threads in a process?
I. Program counter
II. Stack
III. Address space
IV. Registers
Official answer and solution
- Official answer
- B
- From
- Official GATE 2017 answer key
Solution
Differentiate between process-level resources (shared among threads) and thread-specific resources (private to each thread).
In a multithreaded process:
- Address space: All threads of a process share the same virtual address space, including code (text), global/static data, and heap. Thus, III is shared.
- Program counter (PC): Each thread executes instructions independently and requires its own program counter. Thus, I is private to each thread.
- Stack: Each thread needs its own call stack to manage local variables, return addresses, and function activation records. Thus, II is private to each thread.
- Registers: Each thread maintains its own processor register state when scheduled or context-switched. Thus, IV is private to each thread.
Among the options, only the address space (III) is shared by all threads in the process. This matches option B.
B
Assuming stack is shared because threads can technically access each other's memory via pointers; each thread is allocated its own distinct logical stack.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 2
- Question
- 7 of 65, printed as CS Q.7
- 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.