Operating-Systems
October 7, 2023Nielit Scientist-B CS 4-12-2016
October 7, 2023Operating-Systems
Question 42 |
Each Process Pi, i = 1…….9 is coded as follows
repeat P(mutex) {Critical section} V(mutex) forever
The code for P10 is identical except it uses V(mutex) in place of P(mutex). What is the largest number of processes that can be inside the critical section at any moment?
1 | |
2 | |
3 | |
None of the above |
repeat
{
V(mutex)
C.S.
V(mutex)
}
forever
Now, let me say P1 is in CS then P1 is in CS
then P10 comes and executes CS (upon mutex).
Now, P2 comes (down on mutex).
Now P10 moves out of CS (again binary semaphore will be 1).
Now P3 comes (down on mutex).
Now P10 comes (upon mutex).
Now P4 comes (down mutex).
⁞
So, if we take P10 ‘in’ and ‘out’ of CS recursively, all 10 processes can be in CS at same time using binary semaphore only.
repeat
{
V(mutex)
C.S.
V(mutex)
}
forever
Now, let me say P1 is in CS then P1 is in CS
then P10 comes and executes CS (upon mutex).
Now, P2 comes (down on mutex).
Now P10 moves out of CS (again binary semaphore will be 1).
Now P3 comes (down on mutex).
Now P10 comes (upon mutex).
Now P4 comes (down mutex).
⁞
So, if we take P10 ‘in’ and ‘out’ of CS recursively, all 10 processes can be in CS at same time using binary semaphore only.