3k views

A counting semaphore was initialized to $10$. Then $6 P$ (wait) operations and $4V$ (signal) operations were completed on this semaphore. The resulting value of the semaphore is

1. $0$
2. $8$
3. $10$
4. $12$
edited | 3k views

Initially semaphore is $10$, then $6$ down operations are performed means $(10-6=4)$ and $4$ up operations means $(4+4=8)$

So, at last option (B) $8$ is correct.

edited by
6 down and 4 up

that mean we are left with 2 down

and the total is 10 reduce 2 down from it

ans 8
The positive value of semaphore shows the number of successful down() that can be performed on the semaphore. Here 6 successful down() can be performed after that semaphore value will become 4. 1 down() decreases the value of semaphore by 1.

The up() on semaphore increases it's value by 1 & it is always successful. After 4 up() final value of semaphore become 8.

1
2
3
4
5
6