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: | Process Q: |
Synchronization statements can be inserted only at points W, X, Yand Z
Which of the following will ensure that the output string never contains a substring of the form or where n is odd?
P(S) at W, V(S) at X, P(T) at Y, V(T) at Z, S and T initially 1
P(S) at W, V(T) at X, P(T) at Y, V(S) at Z, S and T initially 1
P(S) at W, V(S) at X, P(S) at Y, V(S) at Z, S initially 1
V(S) at W, V(T) at X, P(S) at Y, P(T) at Z, S and T initially 1
According to the question, the output shouldn't contain substrings of the form or where n is odd means any of the processes of P and Q should not be repeated twice concurrently. So, one semaphore is enough for the above problem.
So the correct answer is Option C.