To correctly compute b[i]=g(a[i]) for each index i concurrently:
In each iteration i, Process Y must wait until Process X finishes computing a[i] before Y reads a[i].
Process X should not overwrite a[i] in iteration i+1 before Process Y has read a[i] in iteration i.
Let both binary semaphores be initialized to 0 (R=0,S=0).
In Option (C):
ExitX(R, S):
```cP(S);
V(R);```
EntryY(R, S):
```cV(S);
P(R);```
Trace of execution:
In iteration i=0:
Process X computes a[0]. Then in ExitX, it performs P(S) and blocks because S=0.
Process Y starts EntryY, performs V(S) which signals S (unblocking X), and then executes P(R) which blocks since R=0.
Unblocked Process X continues and executes V(R), which unblocks Process Y.
Process Y is now unblocked and computes b[0]=g(a[0]).
For each subsequent iteration i, this strict lockstep handshake alternates smoothly and ensures a[i] is produced before being consumed, and a[i] is consumed before a[i+1] is produced.
Thus, (C) is the correct implementation.