Suppose we want to synchronize two concurrent processes P and Q using binary…

GATE · 2003 · CS

Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The code for the processes P and Q is shown below.

Process P:
while (1) {
W:
   print '0';
   print '0';
X:
}
	
Process Q:
while (1) {
Y:
   print '1';
   print '1';
Z:
}

Synchronization statements can be inserted only at points W, X, Y and Z Which of the following will ensure that the output string never contains a substring of the form 01^n0 or 10^n1 where n is odd?

  1. A.

    P(S) at W, V(S) at X, P(T) at Y, V(T) at Z, S and T initially 1

  2. B.

    P(S) at W, V(T) at X, P(T) at Y, V(S) at Z, S and T initially 1

  3. C.

    P(S) at W, V(S) at X, P(S) at Y, V(S) at Z, S initially 1

  4. D.

    V(S) at W, V(T) at X, P(S) at Y, P(T) at Z, S and T initially 1

Attempted by 156 students.

Show answer

Correct answer: C

The worked solution is available to enrolled students.

Video solution available to enrolled students.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…