IT lexicon › Programming › Dining philosophers problem

Dining philosophers problem

Programming På svenska → Updated: 2026-11-16

A classical concurrency puzzle: five philosophers sit at a table sharing two forks between them; each needs both to eat but must coordinate so nobody starves.

Edsger Dijkstra formulated it in 1965 to illustrate deadlock and resource allocation. A naive solution — each philosopher grabs the fork to their left, then waits for the right — leads to deadlock (everyone waits for the fork to their right). Solutions include asymmetric taking (only one philosopher grabs left first), monitors, or other orderings. It's the archetype for all resource-allocation problems where multiple processors share limited resources.

Real-world parallels abound: threads sharing locked data structures, CPUs sharing disk I/O, servers sharing database connection pools. The same circular-wait and resource principles apply everywhere.

← Back to the lexicon