edited by
24,591 views
50 votes
50 votes

Each Process $P_i, i = 1\ldots 9$ is coded as follows

repeat 
    P(mutex)
    {Critical section}
    V(mutex)
forever

The code for $P_{10}$ 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. $1$
  2. $2$
  3. $3$
  4. None
edited by

13 Answers

Best answer
75 votes
75 votes

Answer is (D).
If initial value is $1$//execute $P_1$ or $P_{10}$ first 
If initial value is $0$, $P_{10}$ can execute and make the value $1$.
Since the both code (i.e. $P_1$ to $P_9$ and $P_{10})$ can be executed any number of times and code for $P_{10}$ is 

repeat
{
    V(mutex)
    C.S.
    V(mutex)
}
forever 

Now, let me say $P_1$ is in Critical Section (CS)
then $P_{10}$ comes executes the $CS$ (up on mutex)
now $P_2$ comes (down on mutex)
now $P_{10}$ moves out of CS (again binary semaphore will be 1 )
now $P_3$ comes (down on mutex)
now $P_{10}$ come (up on mutex)
now $P_4$ comes (down on mutex) 
So, if we take $P_{10}$ out of $CS$ recursively all $10$ process can be in $CS$ at same time using Binary semaphore only.

edited by
2 votes
2 votes
10 i.e.  ans D)
2 votes
2 votes
option d) none

all 10 processes can enter the critical section
2 votes
2 votes
consider code for i=1 to 9
initially mutex value set to be 1
so it can allow only 1 processor at a time
now p1 enter into critical section.
by this time remaining all are in block state
i.e blocked processes=2,3,4,5,6,7,8,9
but consider code for 10th process it tells that unblock any process because it contain operation. Because of this it can unblock the processor and send it to the critical section
by doing this process all processes can enter into critical section
so finally there are 10 processes at maximum can enter into critical section
answer is option d none.
Answer:

Related questions

48 votes
48 votes
4 answers
2
25 votes
25 votes
6 answers
3
Kathleen asked Sep 29, 2014
17,430 views
An operating system contains $3$ user processes each requiring $2$ units of resource $R$. The minimum number of units of $R$ such that no deadlocks will ever arise is$3$$...
24 votes
24 votes
3 answers
4
Kathleen asked Sep 29, 2014
5,631 views
The correct matching for the following pairs is:$$\small \begin{array}{cl|cl}\hline \text{(A)} &\text{Disk Scheduling} & \text{(1)} &\text{Round robin} \\\hline \text{...