The semaphore variables full, empty and mutex are initialized to $0$, $n$ and $1$, respectively. Process P1 repeatedly adds one item at a time to a buffer of size $n$, and process P2 repeatedly removes one item at a time from the same buffer using the programs given below. In the programs, $K$, $L$, $M$ and $N$ are unspecified statements.
$P_1$ |
while (1) {
K;
P(mutex);
Add an item to the buffer;
V(mutex);
L;
}
|
$P_2$ |
while (1) {
M;
P(mutex);
Remove an item from the buffer;
V(mutex);
N;
}
|
The statements $K$, $L$, $M$ and $N$ are respectively
- P(full), V(empty), P(full), V(empty)
- P(full), V(empty), P(empty), V(full)
- P(empty), V(full), P(empty), V(full)
- P(empty), V(full), P(full), V(empty)