Five philosophers sit around a table with one fork between each pair and need both adjacent forks to eat; if everyone picks up their left fork at once, they deadlock.
Solutions: allow at most four philosophers to sit at once, impose an ordering on resources (pick up the lower-numbered fork first), make one philosopher pick up forks in the opposite order (asymmetric), or pick up both forks atomically inside a monitor.
It illustrates deadlock, starvation and the need for resource ordering.
Loading…