in Operating System edited by
9,451 views
27 votes
27 votes

Which of the following is/are shared by all the threads in a process?

  1. Program counter
  2. Stack
  3. Address space
  4. Registers
  1. (I) and (II) only
  2. (III) only
  3. (IV) only
  4. (III) and (IV) only
in Operating System edited by
by
9.5k views

1 comment

b

since register is not shared
1
1

5 Answers

40 votes
40 votes
Best answer

Thread is light weight process, and every thread have its own, stack, register, and PC (one of the register in CPU contain address of next instruction to be executed), so only address space that is shared by all thread for a single process.
So, option (B) is correct answer.

edited by
by

1 comment

This Q can be easily answered by eliminating options:  I. PC and IV. Registers are the same thing b/c PC is a register. Hence, both I and IV should be together present or not present at all. WE can see that options A, C and D contain either I or IV but not both. Hence they all are eliminated. Correct answer is Option B) III (Address space) only


Imp Note (Gathered from all GATE PYQs possible): -

OS on per thread basis maintains only 2 things : CPU Register space (PC is included in it) and Stack Space. Therefore, only these 2 things are not shared by all the threads in a process.

What are shared then?

Code Segment, Global Variables, TLB, Page Tables, Code Section, Data Section, Static + Heap Address Space, Permissions, Files. These are all shared.

1
1
3 votes
3 votes
Option B is correct because every thread has it's own stack,register and program counter .hence address space is shared by thread.

1 comment

Threads can share                

1) Code section 

2) Data Section (static and heap data)

3) Address Space

So Option B

Threads cant share Program counter, stack space and registers 

1
1
2 votes
2 votes

Threads can share                

1) Code section 

2) Data Section (static and heap data)

3) Address Space

So Option B

Threads cant share Program counter, stack space and registers 

1 vote
1 vote
Answer:

Related questions