Which of the following is/are shared by all the threads in a process?
- Program counter
- Stack
- Address space
- Registers
View worked solution
Answer: B
In a multi-threaded process, threads share certain resources of the process while maintaining their own individual execution context.
Shared among all threads of a process:
- Address space: All threads share the same virtual address space (including the code section, data section, and heap). Therefore, global variables and dynamically allocated memory are accessible by all threads.
- OS resources: Open files, sockets, and signals are shared.
Private to each thread (Not shared):
- Program Counter (PC): Each thread executes instructions independently, so it must have its own PC to track its execution path.
- Registers: Each thread has its own register set to store its current working state and local CPU computation.
- Stack: Each thread has its own stack to store local variables, function parameters, and return addresses.
Evaluating the given options:
- I. Program counter: Private (Not shared)
- II. Stack: Private (Not shared)
- III. Address space: Shared
- IV. Registers: Private (Not shared)
Thus, only (III) Address space is shared by all threads in a process.
Free practice · Your answers on this page are not saved.
