Models the dining philosophers system, including five ways to avoid deadlock.
The application allows the user to change the current mode, and adjust the time
spent eating/thinking as well as the overall speed.
- The "Original" mode will result in a deadlock.
- The "Six Forks" mode sets up the first philosopher
with a fork in their hand already, eliminating a possible
wait-for cycle.
- The "Alternate Hands" mode alternates between left
and right-handed when setting up the philosophers,
eliminating a possible wait-for cycle.
- The "Butler" mode uses a butler to assign sets of
forks, which eliminates incremental acquisition and a
possible wait-for cycle.
- The "Get Both Forks" mode only allows the philosophers
to get forks atomically, which eliminates incremental acquisition.
- The "Steal Forks" mode allows philosophers to steal the fork of a
neighbour who only has one fork, which allows for pre-emption of forks.
To force the system to deadlock, focus the top-right text box (by clicking on it)
and press d.
The code is released under the
GNU General Public License (GPL).