in Operating System
351 views
2 votes
2 votes

Explanation?? 

in Operating System
351 views

1 Answer

7 votes
7 votes
Best answer

In this question , we are concerned about the deadlock only.So we have to think about the given solution in context of deadlock only not mutual exclusion etc.

Here we have to understand that if in a solution it is possible to do that all philosophers are allowed to pick one chopstick simultaneously then we say deadlock has occured since all of them will wait for other fork and this waiting is indefinite .Hence no one gets a chance to eat.

A deadlock scenario will occur if for instance , all the philosopher's pick up the left chopstick first then right chopstick .But in that case it is possible that all pick up left chopsticks at once.So deadlock situation occurs.

Now we come to the question.

Let us consider an instance for the first option

In this the philosophers numbered 1 , 2 , 5 and 4 are picking their left fork first as shown in the diagram above.But as the constraint is given 1 philosopher has to pick the right fork first.So in this case philosopher no 3 has to pick the right fork first.But it is already acquired by 4.So it is not allowed to do so.So now 2 has left fork also and it can also acquire its right fork also as 3 cannot pick left fork before right fork and right fork is already occupied by 4.

Thus 2 is allowed to eat in analogy that it can access critical section hence deadlock is not there.Similarly to confirm we need to take few more instances like we can choose 1,2,3 and 4 instead of 1,2,5 and 4 and verify.If we get such an instance due to which not a single process is able to enter into critical section although it is free(In this context not a single philosopher is allowed to pick both left and right fork at a time), then the solution suffers from deadlock which  is not the case here.

Similarly we can verify option B as well proceeding in the similar manner and going by the constraint of the option.

Hence both of them are free from deadlock and hence correct if we consider absence of deadlock as the criteria.Hence option C is correct.

selected by

1 comment

Thank You So much Habib Khan.
Nice explanation
1
1

Related questions

0 votes
0 votes
0 answers
2
Amit625 asked in Operating System Dec 31, 2018
292 views
Amit625 asked in Operating System Dec 31, 2018
by Amit625
292 views