Machine-translated by Google. Questions are authored in English.
Top

Discussion

A solution to the Dining Philosophers Problem which avoids deadlock is

  • A.ensure that all philosophers pick up the left fork before the right fork
  • B.ensure that all philosophers pick up the right fork before the left fork
  • C.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
  • D.None of the above

Answer: C

The deadlock-free solution is to let one particular philosopher pick up the left fork first, while all the others pick up the right fork first.

Deadlock occurs when every philosopher holds one fork and waits for the next, forming a cycle. If all of them pick up forks in the same order, left first or right first, that cycle can form. Making one philosopher take the forks in the opposite order breaks the circular wait, so at least one philosopher can always get both forks.

So the first two options both allow deadlock, and since option C works, 'None of the above' is wrong.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.