@ccp
#ifdef fm_standard
.df piece_de_resistance = pi\o"e\(ga"ce de r\o"e\(aa"sistance
#else
.df piece_de_resistance = pi\`{e}ce de r\'{e}sistance
#endif
Dining philosophers
Our pi\`ece de r\'esistance is an implementation of a solution for
the problem of the Dining Philosophers.
Cf. [Dij71], [Ho78].
Five philosophers must spent their time thinking and eating.
When a philosopher wants to eat he must get hold of two forks.
Since only five forks are available, each philosopher must await
his turn.
To avoid the situation where each philosopher sits waiting with
one fork, only four philosophers at a time are allowed in
the dining room.
Since a philosopher needs to know no more than his name,
the dining room and his proper forks he may, after creation, proceed
to enter the cycle of thinking, entering the dining room,
picking up his forks, eating and leaving the dining room to
start thinking again.
\lprog{philopher}{
.ds philosopher.pl
}
A philosopher is admitted to the dining room when less than four
guests are present,
otherwise he must wait for one of his colleagues to leave.
\lprog{room}{
.ds room.pl
}
Forks can only be picked up and then put down.
\lprog{fork}{
.ds fork.pl
}
The ceremony is started by assigning the philosophers their proper forks
and showing them the dining room.
We omit the details of their initiation.
The example demonstrates the synchronization enforced by
accept statements.
Such behavior could not be effected by using
synchronous communication over channels.
In fact, the synchronisation and suspension capability
of the rendez-vous mechanism
makes communication over channels superfluous.
However, communication involving accept statements
and non-logical variables is semantically considerably more
complex, and seems to preclude a declarative semantics.
Apart from this, communication over channels is more efficient.