GATE / CS ARCHIVE

GATE CSE 2000 / QUESTION 1.21

Circular acquisition of binary semaphores

Operating Systems · Deadlocks · Full GATE CSE 2000 paper

GATE 2000, Q1.21 1 mark · MCQ
Report issue

Deadlocks

Question 1.21, GATE 2000: Processes P[0]…P[4] use mutexes m[0]…m[4]. Each waits on m[i], then m[(i+1) mod4], before releasing them. Can this cause thrashing, deadlock, starvation without deadlock, or none?
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Schedule P0,P1,P2,P3 so each acquires its first mutex before any attempts the second. They now hold m0,m1,m2,m3 respectively.

Step 2: P0 waits for m1, P1 for m2, P2 for m3, and P3 for m0. Each resource is held by the next blocked process, creating a circular wait.

Thus deadlock is possible, B. The printed modulus is 4 even though five processes/mutexes are named; the four-process cycle already proves the result without silently changing it to 5. P4 does not remove this cycle.

Original paper, page 3