Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE CS 2010 | Question 45

  • Difficulty Level : Hard
  • Last Updated : 28 Jul, 2021

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

gatecs201042

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

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.



Minimum no. of time 0 printed is twice when execute in this order (p0 -> p1 -> p2 -> p0)

Maximum no. of time 0 printed is thrice when execute in this order (p0 -> p1 -> p0 -> p2 -> p0).

Watch GeeksforGeeks Video Explanation :



Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!