edited by
25,138 views
51 votes
51 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

14 Answers

0 votes
0 votes

 maximum 10 processes can enter in the crictical section at a time.
hence option D should be the right choice.

           
  if the code for the process 10 would be like              

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

 then answer should be 3.

And if code would be like for Process 10
repeat 
    P(mutex)
    {Critical section}
    P(mutex)
forever

then answer should be 1.

0 votes
0 votes
From p1….p9 only one process can run..therefore we will just have 1 in CS and when p10 tries and execute..then 2 process will be in CS and..If p10 again comes mutex will be 3 if he does it again4….he can execute as many times he want….then we would have mutex set to very high value..and at that time..if p1,2,3 pn all tries to execute they will simply do mutex— and enter in CS we would have all the processes in CS that ways….Is my reasoning correct?
0 votes
0 votes
p1(not finished)(preemption occur)  ->  p10(not finished)(preemption occur) -> p2(not finished)(preemption occur) -> (from the start)p10 i run p10 from the start OR (case2)i have to wait till the previous p10 process finish if case 2 is true then only 3 process in cs at maximum          if case 2 i s false i run p10 again then any other process ....so on so this ccase ans=10
0 votes
0 votes

Answer is (D)

Set Mutex = 1
V(mutex) -> increment value of mutex
P(mutex) -> decrement value of mutex

Process enters into CS only when mutex = 1
P10 enters
   mutex = 1    {P10}
P1 enters
   mutex = 0    {P10,P1}
P10 exits
   mutex = 1    {P1}
P10 enters
   mutex = 1   {P1,P10}

P2 enters
   mutex = 0    {P10,P1,P2}
P10 exits
   mutex = 1    {P1,P2}
P10 enters
   mutex = 1   {P1,P2,P10}

P3 enters
   mutex = 0    {P10,P1,P2,P3}
P10 exits
   mutex = 1    {P1,P2,P3}
P10 enters
   mutex = 1   {P1,P2,P3,P10}

....

P9 enters
   mutex = 0    { P10,P1,P2 ... P9 }
P10 exits
   mutex = 1    {P1 ... P9}
P10 enters
   mutex = 1   {P1,P2.... P9,P10}

So maximum 10 process in Critical section at a specific time period.
Options D

Answer:

Related questions

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