edited by
11,079 views
33 votes
33 votes

A solution to the Dining Philosophers Problem which avoids deadlock is to

  1. ensure that all philosophers pick up the left fork before the right fork

  2. ensure that all philosophers pick up the right fork before the left fork

  3. ensure that one particular philosopher picks up the left fork before the right fork, and that all other philosophers pick up the right fork before the left fork

  4. None of the above

edited by

5 Answers

Best answer
36 votes
36 votes

Acc. to me it should be (C) because: according to condition, out of all, one philosopher will get both the forks. So, deadlock should not be there.

edited by
14 votes
14 votes
option C explanation:-

let A,B,C are the three philosophers .....

let A pickup left before right and all other pickup right before left then...now B has picked up right fork and A has picked up left fork ....

and  C is waiting for A ....

now both left and right fork is available for A.(i.e A would finish)...after A ,B and then C......

no deadlock....
6 votes
6 votes

Another way to think is first two options forms a cycle that is a circular wait and all other necsessary conditions are satisfied for dining philosopher's problem. So those two are not possible and third one breaks this circular wait. So it is the correct answer.

6 votes
6 votes

In the Dining Philosophers Problem,

each philosopher needs exactly two chopsticks to eat food but the problem is: each philosopher is going to take one chopstick at a time, which is placed at its right-hand side or at its left-hand side, but remember all should choose in same the manner like it first one chooses in a clockwise manner then each one should choose in clockwise, this type of picking  causes a circular waiting loop because each one is depending on other. This is also called as circular waiting and it leads to deadlock.

To avoid this, at least one philosopher should choose its first chopstick in different way so that that circular loop is not formed.

edited by
Answer:

Related questions

23 votes
23 votes
1 answer
1
Kathleen asked Oct 9, 2014
5,706 views
A critical section is a program segmentwhich should run in a certain amount of timewhich avoids deadlockswhere shared resources are accessedwhich must be enclosed by a pa...
45 votes
45 votes
5 answers
4