GATE CS 2024 Set 1 | Question 40
Operating Systems › Process Synchronization · MCQ · 2 marks · Answer: A
- Question 40Operating Systemsmcq2 marksThreads T1 (a=a+1; b=b+1) and T2 (b=2*b; a=2*a), initially a=b=1, each statement atomic. Which option lists all possible (a,b) after both finish?
- A.(4,4); (3,3); (4,3)✓
- B.(3,4); (4,3); (3,3)
- C.(4,4); (4,3); (3,4)
- D.(2,2); (2,3); (3,4)
Answer: A
Solution
Answer: (A) (a = 4, b = 4); (a = 3, b = 3); (a = 4, b = 3) T1: a=a+1; b=b+1. T2: b=2b; a=2a. Each statement is atomic; initially a=b=1. Final depends on the order of "a=a+1" (T1) and "a=2a" (T2); final on "b=b+1" (T1) and "b=2b" (T2). - T1 fully before T2: -> (4,4). - T2 fully before T1: -> (3,3). - Interleave (b=2b, a=a+1, b=b+1, a=2a): -> (4,3). - (3,4) is NOT reachable: needs "a=2a" before "a=a+1", which forces "b=2b" before "b=b+1", giving (not 4). Reachable set = option (A). - A.
More GATE PYQ on Process Synchronization
All GATE CS Operating Systems PYQ →Attempt GATE CS 2024 Set 1 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →