• edited by
2,590 views
6 6 votes
Let S be a binary semaphore variable, S=0

What will be the value of S when following operations are performed:-

2P, 4V, 5P, 2P, 8V, 3P, 2V  ?

1 Answer

Best answer
7 7 votes
Answer is 0.

initially s=0.

Now, 2P makes 2 processes waiting in queue

4V signals will make 2 of them to complete and final value of s=1 now

5P processes one of them will make s=0 and other 4 will wait

2P process further wait making in all 6 processes to wait

8V will make them complete and finally 2V extra signals make s=1

3P, 1p will complete s=0 and 2P will wait

2V will make them to complete and since no extra signal i.e., V so s remains 0
• selected by
Position:
Show:

Related questions

3 3 votes
3 3 answers
4.3k
4.3k views
rahul sharma 5 asked Dec 18, 2017
4,339 views
Consider program for P1 and P2:Here, m and n are binary semaphore variables whose values are initially initialized to 1. x and y are shared resources whose values are in...
1 1 vote
1 1 answer
2.8k
2.8k views
balraj_allam asked Dec 28, 2018
2,813 views
Consider the following statements:S1 : Multiprogramming is used to increase CPU utilization, while time-sharing is used to increase CPU responsiveness in interacting wit...
2 2 votes
1 1 answer
1.2k
1.2k views