Labs / Computer Science
Dining Philosophers
Five philosophers sit around a table, endlessly alternating between thinking and eating, but each one needs both neighbouring forks to eat. Start with the naive strategy and watch the table freeze when everyone grabs their left fork at once, then switch strategies to see how computer scientists dodge that trap. Tap any stuck philosopher to make them drop their forks and break the jam.
Eating 0Meals 0Status running
What to try
- With the naive strategy, what makes the whole table stop at once — and why can no one ever recover on their own?
- Once it deadlocks, tap a single philosopher. Why does freeing just one seat get everyone eating again?
- Switch to resource ordering. Which philosopher now reaches for a different fork first, and how does that one change break the cycle?
- The arbitrating waiter never deadlocks — but does the whole table ever eat at the same time? What is it trading away?
- Crank the speed up and shorten the think time. Does the naive table deadlock faster, slower, or just as unpredictably?