The GATE Grind

GATE 2013 CS (CS1) – Question 49

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

X computes a[i]=f(i), then ExitX(R,S), for i=0,…,n−1. Y calls EntryY(R,S), then computes b[i]=g(a[i]), for each i. R,S are binary semaphores initially zero. Which implementation correctly synchronizes the arrays?

  1. ExitX: P(R);V(S). EntryY: P(S);V(R).
  2. ExitX: V(R);V(S). EntryY: P(R);P(S).
  3. ExitX: P(S);V(R). EntryY: V(S);P(R).
  4. ExitX: V(R);P(S). EntryY: V(S);P(R).

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) ExitX: P(S);V(R). EntryY: V(S);P(R).

Explanation

C implements a rendezvous: Y first signals S to announce readiness, then waits on R. X waits for that S signal after producing a[i], then signals R to release Y. Consequently no ready signal is lost through multiple increments of a binary semaphore, and Y consumes only produced elements. A initially deadlocks and B can lose signals if X outruns Y; D can similarly let binary signals coalesce. Thus C.

More Concurrency and Synchronization questions

All Concurrency and Synchronization questions →