1 / 16

Generalized dining philosophers

Generalized dining philosophers. Catuscia Palamidessi, INRIA in collaboration with Mihaela Oltea Herescu, IBM Michael Pilquist, PSU. Plan of the talk. What we mean by “Generalized dining philosophers” two levels of generalization Motivations

ijohnson
Download Presentation

Generalized dining philosophers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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). ENS Cachan

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

  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 ENS Cachan

  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 ENS Cachan

  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 won’t 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 ENS Cachan

  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. ENS Cachan

  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 R’i Q S f Si 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. ENS Cachan

  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 pinto an asynchronous language. ENS Cachan

  10. The algorithm of Lehmann and Rabin • 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) • goto 1 ENS Cachan

  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 fairschedulers • 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 ENS Cachan

  12. The algorithm of Lehmann and RabinModified so to avoid the need for fairness • 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) • goto 1 ENS Cachan

  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: ENS Cachan

  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 ENS Cachan

  15. 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 ENS Cachan

  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 & 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. ENS Cachan

More Related