Describe the Dining Philosophers problem. What solutions prevent deadlock in it?

Last updated 5 July 2026

  • Five philosophers share five forks and each needs both adjacent forks to eat. If all grab their left fork first, a circular wait forms and everyone deadlocks.

  • Fixes: resource ordering (always take the lower-numbered fork first), allowing at most N-1 at the table via a counting semaphore, atomic pickup of both forks, or asymmetry (odd left-first, even right-first).

  • Deadlock freedom alone doesn't stop an individual philosopher from starving. A fair scheduling policy is still needed.

  • https://apoorvasn.medium.com/solving-the-dining-philosophers-problem-with-mutex-locks-and-c-programming-cee5ac8d35e7
  • https://www.tutorialspoint.com/article/dining-philosophers-problem-dpp
  • https://www.geeksforgeeks.org/quizzes/advanced-synchronization/
  • https://dev.to/plainsight16/concurrency-in-java-the-dining-philosophers-problem-nko
  • https://www.geeksforgeeks.org/operating-systems/inter-process-communication-ipc/
  • https://www.geeksforgeeks.org/operating-systems/dining-philosophers-solution-using-monitors/
  • https://www.geeksforgeeks.org/operating-systems/synchronization-concurrency-interview-questions/
All Operating Systems interview questions