Generalized dining philosophers - PowerPoint PPT Presentation

About This Presentation
Title:

Generalized dining philosophers

Description:

vertices forks. Of course, the problem is interesting when there is at least one cycle ... Each phil needs an arbitrary number of forks ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 17
Provided by: catusciapa
Category:

less

Transcript and Presenter's Notes

Title: Generalized dining philosophers


1
Generalized dining philosophers
  • Catuscia Palamidessi, INRIA
  • in collaboration with
  • Mihaela Oltea Herescu, IBM
  • Michael Pilquist, PSU

2
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).


3
Dining Philosophers classic case
  • Each philosopher needs exactly two forks
  • Each fork is shared by exactly two philosophers

4
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

5
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

6
Intended properties of soln
  • Deadlock freedom (aka progress) if there is a
    hungry philosopher, a philosopher will eventually
    eat
  • Starvation freedom every hungry philosopher will
    eventually eat (but we wont consider this
    property here)
  • Robustness wrt a large class of adversaries
    Adversaries decide who does the next move
    (schedulers)
  • Fully distributed no centralized control or
    memory
  • Symmetric
  • All philosophers run the same code and are in the
    same initial state
  • The same holds for the forks


7
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 p-calculus (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 p-calculus can be
    implemented in a distributed, modular way.


8
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

f
Pi
P
R
f
Ri
Qi
Ri
Q
S
f
f
Si
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.
9
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
The algorithm of Lehmann and Rabin
  1. Think
  2. choose first_fork in left,right commit
  3. if taken(first_fork) then goto 3
  4. take(first_fork)
  5. if taken(first_fork) then goto 2
  6. take(second_fork)
  7. eat
  8. release(second_fork)
  9. release(first_fork)
  10. goto 1

11
Problems
  • Wrt to our encoding goal, the algorithm of
    Lehmann and Rabin has two problems
  • It only works for certain kinds of graphs
  • 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
    Herescus PhD thesis

12
The algorithm of Lehmann and RabinModified so to
avoid the need for fairness
  1. Think
  2. choose first_fork in left,right commit
  3. if taken(first_fork) then wait
  4. take(first_fork)
  5. if taken(first_fork) then goto 2
  6. take(second_fork)
  7. eat
  8. release(second_fork)
  9. release(first_fork)
  10. goto 1

13
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

14
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
15
Proof of the theorem
  • The initial situation has probability p gt 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 gt 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

16
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 Rabins
  • 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.
Write a Comment
User Comments (0)
About PowerShow.com