PHIL = (sitdown -> right.get -> left.get
-> eat -> left.put -> right.put -> arise -> PHIL).
FORK = (get -> put -> FORK).
||DINERS(N=5) = forall [i:0..N-1]
( phil[i]:PHIL
|| {phil[i].left, phil[((i-1)+N)%N].right}::FORK).
One solution permits only 4 philosophers to sit down at any time.
Specify a BUTLER process which, when composed with
DINERS, implements this,
i.e. permits a maximum of four philosophers to engage
in a sitdown action before
an arise action occurs.
Specify an extended sysem, being the composition of the diners with
the butler process.
Hint: seperate FSP processes will model each thread. For thread 0,
model the
execution of the critical and non-critical regions by the
actions t0.crit.enter, t0.crit.exit and
t0.noncrit.enter and t0.noncrit.exit
(and similarly for thread 1). The other
actions are the reading and writing of
the turn, inCS0 and inCS1 variables. These
can be modelled as {t0,t1}::turn:VAR etc, using a simplified
version of the VARIABLE process for TuteLab-1.
VAR = VAR[0],
VAR[i:0..1] = ( read[i] -> VAR[i]
| write[j:0..1] -> VAR[j] ).
The if-else construct will be useful
for modelling the sub-process corresponding to the while loops, e.g.