Which of the following are NOT shared by the threads of the same process? (a)…
2019
Which of the following are NOT shared by the threads of the same process?
(a) Stack
(b) Registers
(c) Address space
(d) Message queue
- A.
(a) and (d)
- B.
(b) and (c)
- C.
(a) and (b)
- D.
(a), (b) and (c)
Attempted by 328 students.
Show answer & explanation
Correct answer: C
Answer: Stack and Registers are not shared by threads of the same process.
Why: threads have separate execution contexts.
Each thread has its own stack and its own CPU registers. The stack holds the thread's local variables and call frames; registers hold the thread's immediate execution state. These are private to the thread.
Threads in the same process share the process address space, which includes the code segment, heap, and global/static variables. They also share process-level resources such as file descriptors and message queues.
Therefore, the items not shared between threads are the stack and the registers; address space and message queues are shared.
Quick example: Two threads can read and write the same global variable (shared address space), but each thread has its own local variables stored on its own stack.
A video solution is available for this question — log in and enroll to watch it.