edited by
24,594 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

1 votes
1 votes
Pi,i =1....9                                            pi=10

P(mutex)                                             v (mutex)

{critical section}                                {cs}
    
V(mutex)                                           v(mutex)

forever         

here p1 enters to cs remaining all gets blocked(suspended list)
for p(10) seperate code given which all are of up operation so when ever up opn is performed it wakes up one process from the suspended list.... hence all 10 will be in critical section... hope u got it
1 votes
1 votes

Here when Pi ,where i=1,2,.....,9 so 

repeat 
    p(mutex)
    {Critical section}
    v(mutex)
forever 

in this code P means down operation and V means up operation , initially  mutex value=1; now for a down operation it will be decreased by 1 which will be 0 now it will check the value is < 0 or > 0 we are watching that value is 0 means process can enter in to the CS. (HERE P1 IS IN C.S) other processes will come in order to enter into the CS but they again decrease the value by 1 which means the value will be less than 0, so all the process p2,p3,p4,p5,p6,p7,p8,p9 will be blocked. and stored in a queue.

NOW

repeat 
    V(mutex)
    {Critical section}
    P(mutex)
forever     p10, will execute it will perform V means UP operation so it will increase the value by 1, and because of this one process will come outfrom the queue from(p2 to p9 any process can come here we are using queue so it will come in FIFO order) again UP again one process come out this will continue...... so in last all the processes in the  C.S 

Answer =10

1 votes
1 votes

 (D) Consider code for i= 1 to 9 Initially mutex value set to 1, so it can allow only 1 process at a time. Now p1 enter into critical section and 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 processes and send it to the critical section. By doing this all processes can enter into critical section. So, finally there are 10 processes at maximum can enter into critical section. Alternative Way- There is loop which runs forever So P10 runs forever. And it has capability to put all other processes to Critical Section. Moreover they Asked Maximum Number of process that can be Present at critical Section So Answer is 10. Option (D) is correct.

1 votes
1 votes

Answer (d)

 

Since we need to find the max process in CS.

We will find a case in which maximum process can be in CS.

 

Let’s say P1,P2….P9  started to execute. [DOWN()]

P1: Will go to CS and mutex value will be change to 0. [ mutex=0 ]

Rest of the Processes [P2,P3…..P9 ] will be blocked as mutex is 0 and will be put in the blocked Q.

Now ,

P10 will start its execution and it will perform 2 UP() operations while going 1 time through the CS.

As it says, process can execute any number of times. 

So, P10 can execute any number of times.

Each time when UP() will be performed it will wake up 1 Process from the Blocked Q  ..

and  woken up Process can go to CS

after sometime Blocked Q will be empty.

And at one point of time all process P1,P2,P3….P10 will be in CS.

 

 

Answer:

Related questions

48 votes
48 votes
4 answers
2
25 votes
25 votes
6 answers
3
Kathleen asked Sep 29, 2014
17,431 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{...