retagged by
469 views
1 votes
1 votes
Let S be the binary semaphore variable initialized to zero. If no blocked processes exist in the system then consider the execution of the following signal (V), wait (P) operation. The number of blocked processes at the end are _________.

                                         4 P, 6 V, 9 P, 13 V, 14 P
retagged by

3 Answers

1 votes
1 votes
is 13 the answer?

4P means 1 process in cs and 3 blocked

6V unblocks all the blocked process

9P = 8 blocked, 1 in cs

13 V similarly unblocks,

finally 14P means 1 block in cs and rest 13 blocked??
edited by
0 votes
0 votes

@Sagar475

Here Semaphore is Binary  ….

So if S=0 and if down or P or wait is performed on S it will remain 0 irrespective of the count of down performed in continous order ….

 

And if S=1 and if up

or

V or signal is perforned on S it will remain 1 irrespective of the count of UP performed in continous order ...

So ,

Here s=0 intitally ....

 

#) 4p i.e 4 down on S , s will remain 0 but 4 process will get blocked …

 

  ##) 6v i.e 6 up on S , s will raise to 1 and all 4 process will get unblock and will execute..

 

###) 9p i.e 9 down on S, s will decement to 0 after 1 down and rest 8 down will cause 8 process to get blocked …

####)13 V i.e 13 up on S , s will increment to 1 and will unblock all the 8 processes ….

 

#####) 14P i.e 14 down on S , it will decrement S to 0 after 1 down and rest all 13 down will cause 13 processes to get blocked....

 

 

1. https://gateoverflow.in/112222/Semaphor-blocked-processes