Live philosophers

This version of dining philosophers (without a possibility of a deadlock) from [#!Janousek:1994:OOPN!#] demonstrates the inheritance concept in OOPN.

Let us have look at class Facility. Note that examinating state of a Facility[*]) via method test is a bit problematic because a message sending is not an atomic operation and thus the state can change before the test finishes. This problem can be solved by means of synchronous ports. Nevertheless, in order to demonstare other PNtalk features we use another solution (demonstarion of synchronous ports application will be done later).

Class Fork (see fig. [*]) inherits from Facility and defined method seizeNowOrNever:. If the facility (fork) is seized, the nethod seizeNowOrNever: does not wait until it is released. Instead, i immediately finishes and returns #fail.

Original method seize: is modified in order to allow modification of the state of a facility only in mutual exclusion with method seizeNowOrNever. New implementation of seize: uses pevious implementaion via super. 3

\epsfig{file=phils-fork.eps}

Class Fork allows us to create a model of dining philosophers which seize forks sequentially as in previous model, but in a case that a fork can not be seized, the respective philosopher releases a fork he already owns and then starts searching for both forks again (see class LPhilosopher (live philosopher) on fig. [*].

\epsfig{file=phils-livephil.eps}

Class LDinner (see fig. [*]) redefined transition t (which is inherited from Dinner) in order to disable its firing because deadlock detection is obsolete in this model. The transition t have the only input place deadlock detected which remain empty (this place lost its original meaning).

\epsfig{file=phils-livedinner.eps}



Vladimir Janousek
2001-01-15