← 💻 Computer Science
⛔ DEADLOCK — every philosopher is stuck holding one fork

🍴 Dining Philosophers

State: Running
Meals served: 0
Waiting (holding 1 fork): 0
Deadlocks hit: 0
FPS:
Thinking Waiting (1 fork) Eating Deadlocked
Drag — rotate · Scroll — zoom

🍴 Dining Philosophers Deadlock Simulator

Five (or more) philosophers sit at a round table, alternating between thinking and eating, but each needs both the fork to their left and the fork to their right — shared resources that can trigger deadlock or starvation depending on how they're acquired.

🔬 What It Demonstrates

Naive "grab left, then right" locking lets every philosopher seize one fork and wait forever for the next — a circular wait that freezes the whole table red. Resource ordering and a waiter/arbitrator strategy both break that cycle and keep meals flowing.

🎮 How to Use

Pick a locking strategy, adjust the number of philosophers and simulation speed, and watch fork colour and philosopher state (grey/yellow/green/red) evolve live. Reset the table to try a fresh run under the same strategy.

💡 Did You Know?

Deadlock needs four conditions at once — mutual exclusion, hold-and-wait, no preemption, and circular wait. Breaking just one, as resource ordering does, makes deadlock structurally impossible regardless of scheduling luck.