Five philosophers sit around a circular table. Between each pair lies a single fork, so there are exactly five forks for five diners. A philosopher alternates between thinking and eating, and to eat she needs both the fork on her left and the one on her right.
The rule sounds civilized: pick up your left fork, then your right fork, eat, put them back. But picture the worst moment — everyone gets hungry at once. Each philosopher grabs her left fork simultaneously. Now every fork is held, every philosopher waits for the neighbor on her right to let go, and that neighbor is waiting too.
Nobody is doing anything wrong. Nobody will ever eat again. This frozen circle of polite waiting is deadlock, and the table is the cleanest picture computer science has of it.
Comments
Loading comments...