608 views
0 votes
0 votes

 

I know that C is the option but i think that b) S0 = 0 , S1 = 1 , S2 = 0 is also true ....means (b and c ) also hold true conditions
but in the MCQ b and c is not in the options that's why  Only C is the correct answer...
please tell me that I right or wrong ??

2 Answers

1 votes
1 votes

Good Observation but you miss one thing ..

Now have look at Option B

We have S0=0 the S1=1 and the S2=0 ..now 

We can only execute the Process P1 so 

Down(S1) so S1=0 now and we have Up(S0) so S0=1 and S2=0 ...

So we can execute the Process P0 ..Down(S0) so S0=0 and Printf...And UP on S1 and S2 so S1=1 and S2=1 ....

No problem upto this ....we have correcty printed the statement Exactly once ...

But look at semaphore we have 

S0=0 the S1=1 and S2=1 ....

You cant execute P1 REASON : its not in the LOOP of while and we have already executed it once so P1 option is gone ..

But we can go For P2 

So Down on S2 possible and S2=0 but S1 already 1 and even if we perofrom UP on S1 we have S1=1 only ...

That's it ...You are freeze ..you cant do anything as semaphore values are 

S0=0 ; S1=1 and S2=0 ....

Now you cant execute P2 and P1 as they are already executed once ..

so OPTION B fails ..

Point to be observe is P1 and P2 are not in infinite LOOP they can be executed only once ...

 

1 votes
1 votes
@Magma Here in this question there is mistake

When $P2$ will execute then then it should perform   $UP(S0)$ but in question it is given that it will perform up on $S1$ due to which it will print Gate @ravindra exactly two time not atleast two

For atleast two it $P2$ must perform $UP(S0)$ then only it can print gate @ravindra atleast two time now

There are only two possible execution sequence 2 possible execution sequence here:

P0→P1→P0→P2→P0  
P0  executed thrice here will print gate @ravindra thrice

P0→P1→P2→P0
 P0 is executed twice only.

Hence, answer is "at least twice"



Coming to your option b)@ Shubham Shastri has already given good reason for it

No related questions found