59.9k views
1 vote
At a particular time of computation the value of a counting semaphore is 7.Then 20 P operations and 15 V operations were completed on this semaphore.The resulting value of the semaphore is : (GATE 1987)

a) 42
b) 2
c) 7
d) 12

1 Answer

3 votes

Final answer:

The final value of a counting semaphore that started at 7 and then underwent 20 P operations and 15 V operations is 2. This is because P operations decrement and V operations increment the semaphore's value. Option (b) is the correct answer.

Step-by-step explanation:

The question involves understanding the operations on a counting semaphore in operating systems. A semaphore is a synchronization primitive used to manage access to a shared resource in concurrent processes.

Initially, we are given that the semaphore has a value of 7. Then 20 P (wait) operations are performed, followed by 15 V (signal) operations.

A P operation decreases the semaphore's value by one, while a V operation increases it by one. Therefore, after performing 20 P operations, the semaphore's value will decrease by 20, resulting in: 7 - 20 = -13. Next, we perform 15 V operations, increasing the semaphore's value by 15, which gives us: -13 + 15 = 2.

Conclusively, the final value of the semaphore after the 20 P operations and 15 V operations is 2, making option (b) correct.

User Joe Warner
by
7.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories