GATE | GATE CS 2010 | Question 45

The following program consists of 3 concurrent processes and 3 binary semaphores.The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.

gatecs201042

How many times will process P0 print ‘0’?
(A) At least twice
(B) Exactly twice
(C) Exactly thrice
(D) Exactly once


Answer: (A)

Explanation: Initially only P0 can go inside the while loop as S0 = 1, S1 = 0, S2 = 0.



P0 first prints ‘0’ then, after releasing S1 and S2, either P1 or P2 will execute and release S0. So 0 is printed again.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.