The Dining Philosphers Problem

In the Dining Philosophers problem, n philosophers sit around a table, with a large plate of food in front of them. There are n forks on the table, each positioned between a pair of philosophers. Each philospher things for an arbitrary amount of time before becoming hungry and attempting to eat, picking up the fork to their left and right. After eating their fill, the philospher puts down their forks, and returns thinking.

Since there are only n forks on the table, the simultaneous access to a single fork would result in a race condition. The goal is to develop a strategy that all philosophers can follow that ensures that no philosopher starves (i.e., waits forever to eat), that no thinking philosopher prevents a hungry philosopher from eating. The strategy should also prevent scenarios when all the philosophers “block” each other in such a way that no one can eat (deadlock and livelock).

The video below illustrates all of these concepts:

Here are separate videos that illustrate each of these concepts in isolation.

Deadlock

The following video illustrates an instance of deadlock.

Livelock

The following video illustrates an instance of livelock.

Odd Even Check

The following video illustrates the “Odd-Even check” algorithm, which enables all the philosphers to think, and eat when hungry.

You have attempted of activities on this page