Once up on a time ... [Dij71] 0 4 1 3 2 No deterministic symmetric dining solution [RL81] Probabilistic symmetric solution T raditional non-symmetric: Left-Righ t solution
Generalized dining philosophers [Lyn81] . . . following: Now: . . . . . Con�ict graph, � = degree . � Eac h philosopher has an arbitrary n um b er of neigh b ours � 9 one fork b et w een ev ery pair of neigh b ours � Eac h philosopher needs all adjacen t forks to eat � Requiremen ts: Exclusion: Disallo w neigh b ours to eat sim ultaneously + no deadlo c k, no starv ation
Drinking philosophers [CM84] . . . i need these bottles hick! . . . . . . � 9 one b ottle b et w een eac h pair of neigh b ours � Eac h thirst y philosopher needs a (presp eci�ed) subset (ma y di�er eac h time) of its inciden t b ottles to drink � Requiremen ts: Exclusion: Allo w neigh b ours to drink sim ultaneously , pro vided that they need to drink from di�eren t (presp eci�ed) b ottles + no deadlo c k, no starv ation
Mobile Philosophers [GPT96] ooo ooo ooo ooo ooo ooo ooo ooo ooo base station ooo ooo ooo user (philosopher), mobile host Channel (F requency) Allo cation � F requency sp ectrum same in eac h cell � Eac h philosopher needs some (arbitrary , not presp eci�ed) subset of frequencies to comm unicate ooo ooo ooo � Requiremen ts: Exclusion: Allo w c hoice of frequencies so as to mak e it p ossible for neigh b ours to op erate sim ultaneously + no deadlo c k, no starv ation � Request satis�abilit y (Bandwidth Utilisation)
General Requiremen ts Exclusion Di�eren t constrain ts and �exibilit y for eac h v ersion No deadlo c k No starv ation Ev aluation Criteria Time and comm unication complexit y (to satisfy a request) (units dep end on the comm unication system) F ault tolerance F ailure lo calit y [CS92] Request Satis�abilit y (for mobile philosophers)
Generalized Left-Righ t Dining [Lyn81] Idea: Color resources (edge-color con�ict graph), C colors p pic ks forks in increasing color order (using m utex for eac h) i color order guaran tees no deadlo c k, no starv ation p Pro cess w aiting c hains i w ait for max-length = C fork color 1 pic k ed b y then w ait for .... = also failure lo calit y p i 1 p i ( C � 1) w ait for T ree giv es w orst case w aiting . . . fork color C then w ait for .... . exp onen tial in C . . pic k ed b y . . . p iC w ait for fork color C then w ait for .... pic k ed b y . . . p , eating iC +1 . . .
Restricting the w aiting c hain length [SP88] Idea: again pic ks forks in increasing color order (using m utex for eac h) but no w: if p pic k ed color 1, 2, . . . x= 2 , . . . need to w ait for color x i bac ktrac k (release forks bac k to x= 2 ) max-w aiting-c hain-length = log C (= also failure lo calit y) in addition: sync hronization do orw a y collect forks w ait for p ermission b y eac h of the neigh b ours to cross log C Time, comm unication complexit y = O (� )
Wh y pic k forks 1-b y-1? Another approac h [CM84] Idea: � Initial Acyclic Orien tation using initial lab eling (e.g. no de coloring) and priviledge tok ens � Sink-no des can eat; then � Rev erse inciden t-edge-direction (send priviledges) Result: dynamic priorit y resolution sc heme can e.g. resolv e p ossible con�icts in the drinking solution W aiting c hain length = O(n) (= failure lo calit y also) (more on acyclic orien tations in [AST94], [BG94])
Con�ict �� Precedence Graph Undirected graph � in which edges rep resent sha red resources b et w een p ro cesses w e call this graph conflict graph � The algo rithm b y Chandy and Misra resolves con�icts b y de�ning fo r every p ossible con�ict a p recedence relation� When t w o p ro cesses comp ete fo r a resource the one � with higher p recedence ma y access the resource �rst� In o rder to receive a solution which is fair these � p recedences will have to change dynamically � The directed graph graph that changes dynamically is called p recedence graph � F o r each resource an edge of the p recedence graph is directed from p ro cesses with lo w er p recedence to p ro cesses with higher p recedence� � T yp eset b y F oil T X � � E
The p recedences of the graph a re chosen such that it is alw a ys p ossible to distinguish at least one p ro cess from all other p ro cesses i�e� this p ro cess can enter its critical section� �NO DEADLOCK� This is ensured b y the existence of at least one p ro cess which has higher p recedence fo r all its sha red resources� A p ro cess with this p rop ert y is called sink � Its existence is gua ranteed when the p recedence graph is alw a ys acyclic� By changing directions of edges it is p ossible to change the p recedences dynamically � This must happ en in a w a y that the p recedence graph sta ys acyclic� so p rogress � fairness and mutual exclusion is gua ranteed� � T yp eset b y F oil T X � � E
Sta rting with a D A G The graph is initialised acyclic fo r example b y a no de� � colouring algo rithm� The graph can remain acyclic if after use of the critical � section a p ro cess reverse all adjacent p recedences in one step� Need a mechanism to k eep the sense of direction� � � T yp eset b y F oil T X � � E
The mechanism F o rks which have the p rop ert y to b e either clean o r dirt y � A fo rk will b e cleanedb efo re it is send to a neighb our � p ro cess� A clean fo rk will b ecome dirt y when the holder of the � resource enters the critical section� After use it remains until it is sent to a neighb our dir ty � p ro cess� � T yp eset b y F oil T X � � E
The dynamic D A G The resp ective p recedence graph H can b e de�ned in � the follo wing w a y� F o r all pairs of p ro cesses p and q which sha re a common � resource� �p�q� one of the follo wing statements is true� �� p holds the fo rk fo r the resource and the fo rk is clean �� q holds the fo rk fo r the resource and the fo rk is dir ty �� the fo rk fo r the resource is in transit from q to p � T yp eset b y F oil T X � � E
Requesting F o rks The request of fo rks is realized b y request tok ens � F o r each fo rk there exist one request tok en such that only the holder of the request tok en can request a fo rk� A hungry p ro cess requests a fo rk b y sending the request to the o wner of the desired fo rk � token A p ro cess is not interested in accessing its resources when it holds a request but not a fo rk � token � T yp eset b y F oil T X � � E
The algo rithm The algo rithm is initialised b y an acyclic p recedence graph H and all p ro cesses with lo w er p recedence o wn dirt y fo rks while p ro cesses with higher p recedence o wn request tok ens� All p ro cesses a re thinking i�e they a re not interested in their resources� A p ro cess which b ecomes hungry will send all its request to neighb our p ro cesses and w ait until it received token all fo rks � A p ro cess which received all fo rks will change its state � to eating � A p ro cess which leaves the critical section � changes the state of all its fo rks to ty � Then dir fo r all held request the resp ective fo rk is sent token to neighb our p ro cesses� The ab ove steps assume follo wing rules� � T yp eset b y F oil T X � � E
Receiving a request fo r fo rk f � token �� If p ro cesso rs state is di�erent from eating and f is then f will b e sent to the requesting p ro cesso r� dir ty �� If p ro cesso rs state w as also hungry then the request will also b e sent back� token a fo rk f � The state of f will b e set to clean� Receiving � T yp eset b y F oil T X � � E
Recommend
More recommend