About the Dining Philosophers:

In 1965, Dijkstra posed and solved a synchronization problem he called the Dining Philosophers problem. Since that time, everyone inventing yet another synchronization primitive has felt obligated to demonstrate how wonderful the new primitive is by showing how elegantly it solves the Dining Philosophers problem. The problem can be stated quite simply as follows. Five philosophers are seated around a circular table. Each philosopher has a plate of spaghetti. The spaghetti is so slippery that a philosopher needs two forks to eat it. Between each pair of plates is one fork. The layout of the table is illustrated below.

The life of a philosopher consists of alternate periods of eating and thinking. (This is something of an abstraction, even for philosophers, but the other activities are irrelevant here.) When a philosopher gets hungry, she tries to acquire her left and right fork, one at a time, in either order. If successful in acquiring two forks, she eats for a while, then puts down the forks, and continues to think. The key question is: Can you write a program for each philosopher that does what it is supposed to do and never gets stuck? (It has been pointed out that the two-fork requirement is somewhat artificial; perhaps we should switch from Italian food to Chinese food, substituting rice for spaghetti and chopsticks for forks.)

(Text obtained from Andrew S. Tanenbaum's "Modern Operating Systems, 2nd ed.")


About the Program:

This is a simulation for Dijkstra's Dining Philosophers problem. The MFC application was developed by Jason M. Chu of Boston University as a programming assignment for Software Design (SC447, Fall 2001). This assignment will demonstrate the basics of semaphores and multi-threaded programming. All user interactions will be managed by the UI thread and the philosophers will be represented as worker threads. Upon the changing of state in a worker thread, a message will be send to the UI thread for updating the graphics onscreen. The application was first developed in the Microsoft Visual Studio 6.0 environment and was later imported to Microsoft Visual Studio .NET.