-
The P and V operations on counting semaphores, where s is a counting semaphore, and defined as follows P(s): s = s – 1;
if s < 0 then wait;
V(s): s = s + 1;
if s < = 0 then we ke up a process waiting on s;
Assume that Pb and Vb the wait and signal operations on binary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows
P(s): Pb (Xb);
s = s – 1;
if (s < 0) {
Vb (Xb);
Pb (Yb);
}
else Vb (Xb);
V(s): Pb (Yb);
s = s + 1;
if (s < = 0) Vb (Yb);
Vb (Xb);
The initial values of Xb and Yb are respectively
-
- 0 and 0
- 0 and 1
- 1 and 0
- 1 and 1
- 0 and 0
Correct Option: C
From the given code we get that P(S) and V(S), decrement and increment the value of semaphore respectively. So, from the given conditions we conclude that to avoid mutual exclusion in the value of Xb should be 1 and that of Yb should be 0.