Generalized
dining
philosophers
Catuscia Palamidessi, INRIA
in collaboration with
Mihaela Oltea Herescu, IBM
Michael Pilquist, PSU
10 December 2002
ENS Cachan
1
Plan of the talk
What we mean by “Generalized dining philosophers”
two levels of generalization
Motivations
The classic deadlock-free solution by Lehmann
and Rabin
Problems with the classic solution
fairness assumption adversaries
restrictions on the connection structure
A solution for the first generalization (w/o the
fairness assumption)
A solution for the second generalization (w/ fairness
assumption).
10 December 2002
ENS Cachan
2
Dining Philosophers: classic case
Each philosopher needs exactly two forks
Each fork is shared by exactly two philosophers
10 December 2002
ENS Cachan
3
Dining Phils: generalization 1
• Each phil still needs two forks, but
• Each fork can now be shared by more than two philosophers
•We will consider arbitrary graphs
arcs philosophers
vertices forks
•Of course, the problem is
interesting when there is at least
one cycle
10 December 2002
ENS Cachan
4
Dining Phils: generalization 2
• Each phil needs an arbitrary number of forks
• Each fork can be shared by an arbitrary number of phils
•We will consider arbitrary
bipartite graphs
vertices 1 philosophers
vertices 2 forks
•Of course, the problem is
interesting when there is at least
one cycle
10 December 2002
ENS Cachan
5
Intended properties of soln
Deadlock freedom (aka progress): if there is a
Starvation freedom: every hungry philosopher will
Robustness wrt a large class of adversaries:
Fully distributed: no centralized control or memory
Symmetric:
hungry philosopher, a philosopher will eventually eat
eventually eat (but we won’t consider this property here)
Adversaries decide who does the next move (schedulers)
All philosophers run the same code and are in the same
initial state
The same holds for the forks
10 December 2002
ENS Cachan
6
Motivations
To model real systems, in which the relation between
resources and users may be more complicate than a ring
Our main motivation: Distributed and modular
implementation of the mixed choice mechanism of the pcalculus (and CCS, CSP etc.)
mixed choice : both input and output guards are present
(out(a).P1 + in(b).P2) | (in(a).Q1 + out(b).Q2)
P1 | Q1
P2 | Q2
Our approach: use the asynchronous p-calculus (no choice, no
output guards) as an intermediate language. The asynchronous pcalculus can be implemented in a distributed, modular way.
10 December 2002
ENS Cachan
7
Encoding p into ppa
Every mixed choice is translated into a parallel comp. of
processes corresponding to the branches, plus a lock f
The input processes compete for acquiring both its own lock
and the lock of the partner
The input process which succeeds first, establishes the
communication. The other alternatives are discarded
R
S
f
Pi
P
f
R’i
Q
Ri
f Si
Qi
f
The problem is reduced to a generalized DP problem where each fork
(lock) can be adjacent to more than two philosophers (generalization 1).
We are interested in progress, i.e. deadlock freedom.
10 December 2002
ENS Cachan
8
Encoding p into asynchonous p
The requirements on the encoding imply symmetry and full
distribution
There are many solution to the DP problem, but only randomized
solutions can be symmetric and fully distributed.
[Lehmann and Rabin 81] - They also provided a randomized algorithm (for
the classic case)
Hence we have actually considered a probabilistic extension of
the asynchronous p for the implementation.
Note that the DP problem can be solved in p in a fully distributed,
symmetric way
[Francez and Rodeh ’80] – they actually use CSP
Hence the need for randomization is not a characteristic of our
approach: it would arise in any encoding of p into an asynchronous
language.
10 December 2002
ENS Cachan
9
The algorithm of Lehmann and Rabin
9.
Think
choose first_fork in {left,right} %commit
if taken(first_fork) then goto 3
take(first_fork)
if taken(first_fork) then goto 2
take(second_fork)
eat
release(second_fork)
release(first_fork)
10.
goto 1
1.
2.
3.
4.
5.
6.
7.
8.
10 December 2002
ENS Cachan
10
Problems
Wrt to our encoding goal, the algorithm of
Lehmann and Rabin has two problems:
1.
It only works for certain kinds of graphs
2.
It works only for fair schedulers
Problem 2 however can be solved by replacing
the busy waiting in step 3 with suspension.
[Duflot, Friburg, Picaronny 2002] – see also Herescu’s
PhD thesis
10 December 2002
ENS Cachan
11
The algorithm of Lehmann and Rabin
Modified so to avoid the need for
fairness
9.
Think
choose first_fork in {left,right} %commit
if taken(first_fork) then wait
take(first_fork)
if taken(first_fork) then goto 2
take(second_fork)
eat
release(second_fork)
release(first_fork)
10.
goto 1
1.
2.
3.
4.
5.
6.
7.
8.
10 December 2002
ENS Cachan
12
Restriction on the graph
Theorem: The algorithm of Lehmann and Rabin is
deadlock-free if and only if all cycles are pairwise
disconnected
There are essentially three ways in which two cycles
can be connected:
10 December 2002
ENS Cachan
13
Proof of the theorem
If part) Each cycle can be considered separately. On each of
them the classic algorithm is deadlock-free. Some additional
care must be taken for the arcs that are not part of the cycle.
Only if part) By analysis of the three possible cases. Actually
they are all similar. We illustrate the first case
committed
taken
10 December 2002
ENS Cachan
14
Proof of the theorem
The initial situation has probability p > 0
The scheduler forces the processes to loop
Hence the system has a deadlock (livelock) with
probability p
Note that this scheduler is not fair. However we can define
even a fair scheduler which induces an infinite loop with
probability > 0. The idea is to have a scheduler that “gives up”
after n attempts when the process keep choosing the “wrong”
fork, but that increases (by f) its “stubborness” at every round.
With a suitable choice of n and f we have that the probability of
a loop is p/4
10 December 2002
ENS Cachan
15
Solution for the Generalization 1
As we have seen, the algorithm of Lehmann and Rabin does not
work on general graphs
However, it is easy to modify the algorithm so that it works in
general
The idea is to reduce the problem to the pairwise disconnetted
cycles case:
Each fork is initially associated with one token. Each phil needs to
acquire a token in order to participate to the competition. After
this initial phase, the algorithm is the same as the Lemahn & Rabin’s
Theorem: The competing phils determine a graph in which all cycles
are pairwise disconnected
Proof: By case analysis. To have a situation with two connected
cycles we would need a node with two tokens.
10 December 2002
ENS Cachan
16
© Copyright 2026 Paperzz