Philsophers' Forks - Animated
Description
- Five philosophers sit around a table. Each one goes through a cycle of
sleeping and eating.
- There is a fork between each two philosophers, so there are five works
on the table.
- To eat, a philosopher has to grab the forks on both sides. If a fork has
already been taken by the philosopher on the other side of the fork, the
philosopher must wait until that fork is free.
- The philosophers reach for forks in no particular order, but once they
reach out for a fork and have to wait, they don't change their mind, even
if the other fork is available.
- After having finished eating, the philosopher puts down both forks and
goes back to sleep.
- The times that they sleep and eat vary randomly around given values.
Watch the contention between the philosophers as they wake up, wait for
forks, and eat.
Wait until you see all the images - that makes the applet run fast.