Computer Science, asked by ammumenon82, 1 year ago

In a certain application, the initial value of a counting semaphore s is 20. The following operations were completed on the semaphore in the 
   given order 5P, 20P, 2V, 15P, 5V, 10P, 1V. The new value of counting semaphore is  _____________ ? 


Answers

Answered by Raghav1330
0

Answer:-32

Explanation:

We all know that V operation increments or the semaphore value and P operation decrements value of semaphore. As this are counting semaphores then the the no of V or P operation done indicate the final value of semaphore. The no of V operations is multiplied by +1 or -1 depending upon increments and decrement hence we find final value

Here as the initial value is 20

After doing of the operations

5P=20-5= 15

20P=-15

2V=-13

15P=-28

5V=-23

10P=-33

1V=-32

Answered by smartbrainz
0

The new value of counting semaphore is -22

Explanation:

In ‘semaphore’, ‘P means Wait’ and ‘V means Signal’. The ‘P (Wait)’ operation decreases the 'semaphore value by 1’ each time and ‘V (Signal)’ operation will increase the 'semaphore value by 1’ each time.

Here at a specific time of calculation, the value of counting ‘semaphore is 20’.

So,  20 - 5 - 20 + 2 - 15 + 5 - 10 + 1 = -22

Hence, the new value of counting 'semaphore' is -22

To know more

P and v semaphore implementation why while loop and not just if

https://brainly.in/question/9747998

Disadvantage of semaphore and what is the modification in traditional definition of semaphore to solve problem

https://brainly.in/question/1581898

Similar questions