October 7, 2023
October 7, 2023
October 7, 2023
###### Nielit Scientist-B CS 4-12-2016
October 7, 2023
 Question 43

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?

 A 1 B 2 C 3 D None of the above
Question 43 Explanation:
Since the both code (i.e., P1 to P9 and P10) can be executed any number of times and code for P10 is
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.

Question 43 Explanation:
Since the both code (i.e., P1 to P9 and P10) can be executed any number of times and code for P10 is
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.