Dining Philosophers

This example is a refined model of the well-known dining philosophers world. Both forks and philosophers are objects. Forks are instances of class Facility and they can be instantiated by message sending "Facility new". A fork can be seized and then released by a philosopher (it has methods "seize:" and "release:"). Philosophers are instances of class Philosopher. A philosopher can be instantiated by message sending "Philosopher with: LeftFork and: RightFork". A philosopher sequentialy seizes both forks, then he eat and then he sequentialy releases both forks. Enabledness of synchronous port "haveLeft" indicates dangerous situation which can cause deadlock (this will be used in next examples). The whole philosopher's world is represented by an instance of the main class "Dinner". Its sychronous port "dead" will be used in other examples to detect deadlock.

\epsfig{file=phils-facility.eps}

\epsfig{file=phils-philosopher.eps}

\epsfig{file=phils-dinner.eps}



Vladimir Janousek
2001-01-15