2.1k views

There are three processes P1, P2 and P3 sharing a semaphore for synchronising a variable. Initial value of semaphore is one. Assume that negative value of semaphore tells us how many processes are waiting in queue. Processes access the semaphore in following order:

1. P2 needs to access
2. P1 needs to access
3. P3 needs to access
4. P2 exits critical section
5. Pi exits critical section

The final value of semaphore will be:

1. 0
2. 1
3. -1
4. -2
| 2.1k views

initial value of semaphores S=1

1. P2 needs to access decreases it to 0    (no one is waiting)
2. P1 needs to access decreases it to -1   (one process is waiting)
3. P3 needs to access decreases it to -2 ( 2 process r waiting)
4. P2 exits critical section increases it to -1 ( one process is waiting)
5. Pi exits critical section increases it to 0   ( no process is waiting)                                                                                                                    so ans is A
by Boss (49.3k points)
selected
+1 vote

Initially the value of semaphore S is 1.

After (a) S=0
(b) S=-1
(c) S= -2
(d) S= -1
(e) S= 0

ans is A

by Active (1.9k points)
0
3 process operation

So initial value is 1-3+2=0

Ans is A
3 p operation and 2 v operation , so initial value is 1 -3+2=0
by Active (5.1k points)

+1 vote