edited by
10,848 views

3 Answers

Best answer
17 votes
17 votes
Each P operation decreases the value of counting semaphore by 1  and each V operation increases the value of counting semaphores by 1

Here given value of counting semaphore  is 7  then 20 p operation will reduces it to -13

then in order to increase it to 5    18 V operations are needed

hence x=18 ans is A
edited by
11 votes
11 votes

Here,P represents Wait and V represents Signal. P operation decrements the semaphore value by 1 every time and V operation will increments the semaphore value by 1 every time.

At a particular time of computation the value of a counting semaphore is 7.After that 20 P and x V operations were completed on the semaphore.

So,

7 - 20 + x =5

-13 +x=5
 

x=18

edited by
Answer:

Related questions

0 votes
0 votes
1 answer
2
Mrityudoot asked Jan 27
237 views
Can a counting semaphore acquire a negative value?S = 2;15 P operations done, should the semaphore be 0 or -13
0 votes
0 votes
1 answer
3
N3314nch41 asked Sep 10, 2023
361 views
How to approach synchronization (specifically semaphore) question, there size are really intimidating and i’m unable to decode the code written? What to do??