Presentation is loading. Please wait.

Presentation is loading. Please wait.

The stabilizing token ring in three bits Mohamed G. Gouda F. Furman Haddix Presented by: Marc Segal.

Similar presentations


Presentation on theme: "The stabilizing token ring in three bits Mohamed G. Gouda F. Furman Haddix Presented by: Marc Segal."— Presentation transcript:

1

2 The stabilizing token ring in three bits Mohamed G. Gouda F. Furman Haddix Presented by: Marc Segal

3 Self-stabilizing Systems States of a system are partitioned into legal illegal states Every state that is reachable from a legal state is legal The system is stabilizing iff starting from any state the system will reach a legal state in a finite number of state transitions. Illegal states Legal states

4 Unidirectional Stabilizing Token Rings The legal states: –there is exactly one token The illegal states: –No token exists –There is more than one token T TT T TT

5 Unidirectional Stabilizing Token Rings The legal states: –there is exactly one token The illegal states: –No token exists –There is more than one token T TT T TT T TT T TT

6 Reminder: Dijkstra’s algorithm Dijkstra presented three algorithms for a self- stabilizing token ring: –Dijkstra’s 1 st algorithm : every processor is a k-state machine, k>N-2 –Dijkstra’s 2 nd algorithm : 4 states –Dijkstra’s 3 rd algorithm : 3 states However, Dijkstra’s 2 nd & 3 rd algorithms are bi- directional. Is there a deterministic self-stabilizing token ring algorithm that uses less states ? Particularly, is there a deterministic self- stabilizing token ring algorithm that uses a number of states that is not dependent on the number of processors ?

7 A 1-bit algorithm ? Let’s attempt to design a 1-bit self-stabilizing token ring algorithm We would like the algorithm to: –Create a new token when there is no circulating token –Reduce the number of tokens when there is more than one token –Be fair: the token must circulate Some Notations: –Every process has a boolean state variable t. –We denote the variable t of process P i by t.i –t.i is can be read and written by process P i –t.i can be read by process P i+1

8 A 1-bit algorithm ? Let’s try to suggest a 1-bit algorithm Definitions: –We say that a process P i i≠0 has the token if t.i≠t.i-1 –We say that process P 0 has the token if t.0=t.n-1. t.n-1t.0 001 011 100 110 t.i-1t.i 000 010 101 111 11 0 00

9 By defining token possession differently for P 0 and the other processes we ensure that there will always be at least one token. But what about multiple tokens ? How do we reduce the number of tokens? Let’s differentiate between two types of tokens: –If a process P i has a token and t.i=true we say that it has a T-token. –If a process P i has a token and t.i=false we say that it has an F-token. Our goal is to allow T-tokens to move freely, while limiting the movement of F-tokens A 1-bit algorithm ?

10 We now allow only T-tokens to proceed: t.n-1t.0 000 011 100 110 t.i-1t.i 000 010 100 111 0 0000

11 A 2-bit algorithm? We’d still like F-tokens to be able to proceed, only slower than T-tokens. We introduce a new state variable: ready. A node can pass an F-token to its neighbor only if it its ready variable is true. If a node has an F-token and its ready variable is false, it turns it on.

12 A 2-bit algorithm ? Action designator ConditionAction X.0t.0≠t.(n-1)ready:=false Y.0 t.0 = t.(n-1)  (  t.0   ready) ready:=true Z.0 t.0 = t.(n-1)  (t.0  ready) t.0:=  t.0 ready:=false Action desginator, i≥1 ConditionAction X.it.i=t.(i-1)ready:=false Y.i t.i ≠ t.(i-1)  (  t.i   ready) ready:=true Z.i t.i ≠ t.(i-1)  (t.i  ready) t.i:=  t.i ready:=false Would this algorithm work ?

13 2-bit Algorithm Operation - Simulation P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P9P9 t ready P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P9P9 F NextResetSet

14 2-bit algorithm conclusions An F-token must execute two actions each time it proceeds from one process to the next. A T-token needs only execute one. This doesn't work ! The scheduler may allow processes that hold F-tokens to execute two actions, for each action it allows a process that holds a T-token. What schduler would this algorithm work with ?

15 The 3-bits algorithm - Definitions Every process has three boolean variables: –e – determines if the process has an enabler –t – determines if the process has a token –ready A process can make a move only if it has an enabler. –Process P 0 has an enabler if e.0=e.(n-1) –Process P i, i≠0 has an enabler if e.i≠e.(n-1) Similiarly: –Process P 0 has a token if t.0=t.(n-1) –Process P i, i≠0 has a token if t.i≠t.(n-1) If a process P i has a token and t.i=true we say that it has a T-token. If a process P i has a token and t.i=false we say that it has an F-token.

16 Example 0123456789 e0010110000 t0101110001 Is enabled but has no token Has a T- token but is not enabled Is enabled and has an F-token Is enabled and has a T-token Is enabled but has no token Is not enabled and has no token

17 Example 0123456789 e0010110000 t0101110001 An alternative representation: 0123456789 E1E1 T2T2 E2E2 F1F1 E3E3 T3T3 E4E4 E5E5 F2F2 T4T4

18 The 3-bits algorithm Action designator Condition e.0=e.(n-1) Action X.0t.0≠t.(n-1) e.0:=  e.0, ready:=false Y.0 t.0 = t.(n-1)  (  t.0   ready) e.0:=  e.0, ready:=true Z.0 t.0 = t.(n-1)  (t.0  ready) e.0:=  e.0, t.0:=  t.0 ready:=false Action desginator, i≥1 Condition e.i≠e.(i-1) Action X.it.i=t.(i-1) e.i:=  e.i, ready:=false Y.i t.i ≠ t.(i-1)  (  t.i   ready) e.i:=  e.i, ready:=true Z.i t.i ≠ t.(i-1)  (t.i  ready) e.i:=  e.i, t.i:=  t.i ready:=false

19 The 3-bits algorithm Action designator ConditionAction X.ihas enabler & doesn’t have token pass enabler ready:=false Y.ihas enabler & has an F-token &  ready pass enabler ready:=true Z.ihas enabler & (has a T-token or (has an F-token and ready=true) ) pass enabler pass token ready:=false

20 The 3-bits algorithm Action designator ConditionAction X.ihas enabler & doesn’t have token pass enabler ready:=false Y.ihas enabler & has an F-token &  ready pass enabler ready:=true Z.ihas enabler & (has a T- token or (has an F token and ready=true) ) pass enabler pass token ready:=false An X action allows the enabler to pass from process P i to process P i+1 when P i does not have a token A Y action allows the enabler to pass from process P i to process P i+1 when P i has an F- token and its variable ready is false. The variable ready becomes true in this action. A Z action allows the enabler to pass from process P i to process P i+1 when P i has an F- token and its variable ready is true or when it has a T-token. The variable ready becomes false in this action.

21 Algorithm Operation - Simulation P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P9P9 e t ready P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P9P9 E F NextResetSet

22 3-bit Algorithm - Observations In every state: –There is at least one enabler –There is at least one token Enablers can proceed freely –In every one of the X,Y,Z actions the enabler is passed to the next process T-Tokens can proceed only when they are joined by an enabler. –Once a T-Token is joined by an enabler it will “ride” that enabler until it is inverted or annihilated F-Tokens may only proceed if they are joined by an enabler and the ready flag is not raised –This is meant to limit the number of hops an F-token rides the enabler to one hop. Token Inversion –When a T-token is passed from process P n-1 to process P 0 it becomes an F-token –When an F-token is passed from process P n-1 to process P 0 it becomes a T-token Annihilation: –Enabler annihilation occurs when two enablers collide –Token annihilation occurs when two tokens collide –If there is more than one enabler and more than one process makes a move in each step, enabler annihilation may never occur –That is not true for tokens, which is why the algorithm is self stabilizing... SH

23 Proof of Stabilizaiton System Model Ring state –A state S of the ring is defined by one value for every variable in every process. –A legal state is a state in which there is only one token. Enabled Process –A Process is enabled if it has an enabler. Enabled Action –An action (X,Y or Z) is enabled for a process if the action’s condition is true. –Exactly one action is enabled for each enabled process. Transition –( S, S’ ) is a transition of the ring if S’ is generated from S by execution a subset of the enabled actions in S. –A distributed scheduler. Computation –C=S 1,S 2,... is a computation of the ring if: Every S i is a state of the ring. for every pair S i, S i+1 ( S i,S i+1 ) is a transition. SH

24 Proof of Stabilization Lemma 1 Definition: We say that a process P i is e-different if e.i≠e.(i-1) mod n Definition: We say that a process P i is t-different if t.i≠t.(i-1) mod n Definition: For every state S of an n size ring we define: Lemma 1: For every state S, N e-different (S), N t-different (S) are even 011011101 e-different SH

25 Proof of Stabilization Lemma 1 Definition: We say that a process P i is e-different if e.i≠e.(i-1) mod n Definition: We say that a process P i is t-different if t.i≠t.(i-1) mod n Definition: For every state S of an n size ring we define: Lemma 1: For every state S, N e-different (S), N t-different (S) are even 011011101 T If the number of e-different processes in T is even then e.n-1=e.0  The total number of e-different processes is even If the number of e-different processes in T is odd then e.n-1≠e.0  The total number of e-different processes is even SH

26 Proof of Stabilization Lemma 2 Definition: For a state S of the ring, we define: Lemma 2: For every state S or the ring N tokens (S), N enablers (S) are odd. Case 1: N e-different (S) =0 e=0 Only process that has an enabler  N enablers (S)=1 SH

27 Proof of Stabilization Lemma 2 Definition: For a state S of the ring, we define: Lemma 2: For every state S of the ring N tokens (S), N enablers (S) are odd. Case 2: N e-different (S) >0 and P 0 is e-different e=0 e=1e=0 e=1 Is e-different but doesn’t have an enabler  N enablers (S)=N e-different (S)-1 which is odd by lemma 1 Is e-different and has an enabler SH

28 Proof of Stabilization Lemma 2 Definition: For a state S of the ring, we define: Lemma 2: For every state S of the ring N tokens (S), N enablers (S) are odd. Case 3: N e-different (S) >0 and P 0 is not e-different  N enablers (S)=N e-different (S)+1 which is odd by lemma 1 e=1e=0 e=1e=0 e=1 Is not e-different but has an enabler Is e-different and has an enabler SH

29 Proof of Stabilization Lemma 3 Lemma 3:Let P i be a process that holds a token. Let P j, j>i, be the next process to hold a token on the ring. Then, if P i holds a T-token P j holds an F- token and vice versa. P0P0 t=xPiPi PjPj P n-1 Has token  t=  x Doesn’t have a token  t=  x Doesn’t have a token  t=  x Has token  t=x SH

30 Proof of Stabilization Lemma 4 Lemma 4:Let P i,P j j>i be processes that hold a tokens so that no process from P j+1 to P i-1 holds a token. Then, P i and P j hold the same kind of token. Has token  t=  x P0P0 P i-1 PiPi PjPj P n-1 t=x P j+1 Doesn’t have token  t=  x Doesn’t have token  t=  x Doesn’t have token  t=x Doesn’t have token  t=x Has token  t=  x SH

31 Proof of Stabilization Lemma 5 Lemma 5:For every transition ( S,S’ ): – N enablers (S’) ≤ N enablers (S) – N tokens (S’) ≤ N tokens (S) Proof: Let P i be a process that has an enabler in S’ and doesn’t have an enabler in S. Let k be the minimal number for which P i-k does not execute an action in the transition ( S,S’ ). P0P0 P i-k PiPi P n-1 Has no enabler in S  Doesn’t execute any action in (S,S’) Executes an action in (S,S’) Doesn’t execute an action in (S,S’) Must not have an enabler in S’  For every process that gains an enabler there is a process that loses an enabler.  The proof for tokens is identical. SH

32 Lemma 6: Every computation of the algorithm is infinite. Proof: A finite computation ends with a state in which no action is enabled.finite computation A process that has an enabler in some state has exactly one enabled action.enabled action By lemma 2, the number of enablers in any state is odd. Specifically, the number of enablers cannot be zero.lemma 2 Proof of Stabilization Lemma 6 SH

33 Lemma 7: In every computation C, every process has at least one action which is executed infinitely many times. Proof: C is an infinte computation, but the number of processes is finite.  There is a process P i that executes at least one action infinitely many times in C. Assume by contradiction, that P i-1 executes a finite number of actions in C. Let’s examine a suffix of C in which P i-1 doesn’t execute any action. Proof of Stabilization Lemma 7 P0P0 P i-1 PiPi P n-1 Eventually is enabled  e=  x e=x Can’t change, no action is executed After executing an action e=  x=x In order for P i to be enabled again must change value of e Contradiction SH

34 Lemma 7: In every computation C, every process has at least one action which is executed infinitely many times. Proof: For P i to get enabled again after it executes an action, P i-1 must execute an action.  P i-1 executes an infinite number of actions. This is true for every P i, therefore all processes execute infinitely many actions. Proof of Stabilization Lemma 7 SH

35 Definition:A token annihilation is a transition T=(S,S’) in which: –Two adjacent processes P i, P i+1 have tokens in S –P i executes action Z.i in T –P i+1 doesn’t execute any action in T Proof of Stabilization Token Annihilation P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P9P9 F E FT Can execute action Z SH

36 Proof of Stabilization Lemma 8 E T P0P0 PiPi P n-1 P i+1 P i-1 In state S: t=0t=1 Cannot execute action Z before P i, because that would consist token annihilation By lemma 7, will eventually execute an action. Since it holds a T-token can only execute Z action Lemma 8:If C is an annihilation-free computation, and P i has a token at some state S it will eventually execute action Z.i and pass the token to P i +1. If P i = P n -1 the token is passed inverted. Otherwise, it is passed unchanged. SH

37 Proof of Stabilization Lemma 8 E P0P0 PiPi P n-1 P i+1 P i-1 In state S: t=1t=0 Cannot execute action Z before P i, because that would consist token annihilation By lemma 7, will eventually execute an action. Since it holds an F-token and a ready flag can only execute a Z action F SH

38 Proof of Stabilization Lemma 8 E P0P0 PiPi P n-1 P i+1 P i-1 In state S: t=1t=0 Cannot execute action Z before P i, because that would consist token annihilation By lemma 7, will eventually execute an action. Since it holds an F-token and no ready flag can only execute a Y action F Lemma 8:If C is an annihilation-free computation, and P i has a token at some state S it will eventually execute action Z.i and pass the token to P i +1. If P i = P n -1 the token is passed inverted. Otherwise, it is passed unchanged. SH

39 Lemma 9:In an annihilation-free computation C, if some process P i has a token at some state, then eventually it passes the token unchanged from one process to the next until it reaches P n-1. From P n-1 it is eventually passed inverted to P 0. and the cycle continues. Proof: By continous activation of lemma 8. Proof of Stabilization Lemma 9 SH

40 Proof of Stabilization Lemma 10 Lemma 10: Every annihilation-free computation C has an infinite suffix C’ such that in every state S in C’, every process P i has either ready.i=false or ready.i=true and P i has an F-token Proof: We consider a suffix C’ in which every process has already executed at least one action. We examine state S : P0P0 P i-1 PiPi P n-1 If last action was either X or Z then ready=false If last action was Y then ready=true and had an F- token when it exectued it Can’t execute Z action, after P i Because C is annihilation-free SH

41 Lemma 11: Every annihilation-free computation C has an infinite suffix such that the following conditions are satsified: –If an F-token is passed from P i-1 to P i in a transition ( S, S’ ) then ready.i=false in S’ –If a T-token is passed inverted from P n-1 to P 0 in a transition ( S,S’ ), then ready.0=false in S’ Proof: We examine a suffix C’ as in lemma 10. Let ( S,S’ ) be a transition in C’ in which an F-token is passed from P i-1 to P i. Proof of Stabilization Lemma 11 E P0P0 PiPi P n-1 P i+1 P i-1 F Has no token F- token (lemma 3) ready=false (lemma 10) SH

42 Lemma 11: Every annihilation-free computation C has an infinite suffix such that the following conditions are satsified: –If an F-token is passed from P i-1 to P i in a transition (S,S’) then ready.i=false in S’ –If a T-token is passed inverted from P n-1 to P 0 in a transition (S,S’), then ready.0=false in S’ Proof: We examine a suffix C’as in lemma 10. Let (S,S’) be a transition in C’ in which an F-token is passed from P i-1 to P i. Proof of Stabilization Lemma 11 E P0P0 PiPi P n-1 P i+1 P i-1 FT E Must execute action or token will be annihilated SH

43  Theorem 1:Every computation C has an infinite suffix in which each state is legal.legal Proof: Let C be an arbitrary computation of the ring. –By lemma 6, C is infinite.lemma 6 –By lemma 5, The numbers of tokens and enablers in C are non-increasing.lemma 5 –Let C’ be a suffix of C so that in every state there are exactly t tokens, and e enablers. –Let C’’ be a suffix of C’ that satisfies the conditions in lemma 11 lemma 11 Proof of Stabilization Theorem 1 SH

44 We assume by contradiction that t>1. Let S be the first state of C’’ By lemma 3, there must be a T-token in Slemma 3 By lemma 9, the T-token will be passed unchanged until it reaches P n-1 and then will be passed inverted to P 0lemma 9 By lemma 11, after the T-token is passed to P 0, ready.0=falselemma 11 Let S 0 be the state after the T-token is passed to P 0 Since a token cannot be passed without an enabler, P 0 has an enabler in S 0 Proof of Stabilization Theorem 1 SH

45 We denote the F-token in P 0 in S 0 by U. We denote the Enabler in P 0 in S 0 by E. P 0 will eventually execute action 0.Y and pass E to P 1 P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P n-1 U E Proof of Stabilization Theorem 1 SH

46 U will eventually make the journey from P 0 to P n-1, and then be inverted and return to P 0 as a T- token For that to happen, U has to join n enablers One of these enablers must be E P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P n-1 U Proof of Stabilization Theorem 1 E1E1 E2E2 E3E3 E4E4 E5E5 E6E6 E7E7 E8E8 E9E9 E 10 SH

47 We examine the ring after S 0 : –Since t>1, by lemma 3, there must be a least another T- token and another F-token on E ’s path. –Let the first T-token after U be V –Let the first F-token after V be W P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P n-1 U E Proof of Stabilization Theorem 1 WV SH

48 An enabler can’t race past a T-token In order to join U, E must first join V Once E joins V, it will carry V until it is inverted, then drop it at P 0 But then, W will have been inverted too and will stand between E and U For E to reach U it must join W first. If it does it will carry it all the way to U. That would cause U and W to be annihilated. Contradiction. Therefore, t=1. P0P0 P1P1 P2P2 P3P3 P4P4 P5P5 P6P6 P7P7 P8P8 P n-1 U E Proof of Stabilization Theorem 1 WV W V SH

49 Discussion What is the time complexity for stabilization ? Are all the 8 states necessary ? Is it possible to do with less states?


Download ppt "The stabilizing token ring in three bits Mohamed G. Gouda F. Furman Haddix Presented by: Marc Segal."

Similar presentations


Ads by Google