The GATE Grind

GATE 2008 CS – Question 63

Operating System · Concurrency and Synchronization · 2 marks · Multiple choice

Counting semaphore s uses P: decrement s, wait if s<0; V: increment s, wake one waiter if s≤0. Binary primitives Pb, Vb implement it as below. What initial values should xb, yb have?

P(s): Pb(xb); s=s-1;
      if(s<0) { Vb(xb); Pb(yb); }
      else Vb(xb);
V(s): Pb(xb); s=s+1;
      if(s<=0) Vb(yb);
      Vb(xb);
  1. 0 and0
  2. 0 and1
  3. 1 and0
  4. 1 and1

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) 1 and0

Explanation

We are sorry we couldn't write detailed soluition for this, we are working on it!, please consider asking your own AI, its just 2-3 clicks with very minimum effort

More Concurrency and Synchronization questions

All Concurrency and Synchronization questions →