Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 8 - Self-Stabilizing Computing1 Chapter 8 – Self-Stabilizing Computing Self-Stabilization Shlomi Dolev MIT Press, 2000 Draft of January 2004 Shlomi.

Similar presentations


Presentation on theme: "Chapter 8 - Self-Stabilizing Computing1 Chapter 8 – Self-Stabilizing Computing Self-Stabilization Shlomi Dolev MIT Press, 2000 Draft of January 2004 Shlomi."— Presentation transcript:

1 chapter 8 - Self-Stabilizing Computing1 Chapter 8 – Self-Stabilizing Computing Self-Stabilization Shlomi Dolev MIT Press, 2000 Draft of January 2004 Shlomi Dolev, All Rights Reserved ©

2 chapter 8 - Self-Stabilizing Computing2 Chapter 8: roadmap 8.1 The Computation Power of Self-Stabilizing Systems 8.2 Queue Machine

3 chapter 8 - Self-Stabilizing Computing3 The Computation Power of Self- Stabilizing Systems lllllll l n 1 2 n....

4 chapter 8 - Self-Stabilizing Computing4 Modeling the problem  The single processor is modeled by a Universal- Turing-Machine* (UTM)  The distributed system will simulate the UTM in a self-stabilized fashion  The distributed system topology will be a simple chain of n processors, each processor represents a single working cell * note: The use of UTM eliminates the transition table size factor, since we use the code of the algorithm as part of the input

5 chapter 8 - Self-Stabilizing Computing5 Token passing with a constant amount of memory  The distributed system uses a version of Dijkstra’s second mutual exclusion algorithm:  The algorithm simulates a token with a color field of three values P1P1 PnPn

6 chapter 8 - Self-Stabilizing Computing6 Version of Dijkstra’s mutual exclusion algorithm: 01 P 1 02 lr 2,1.color  r 2,1.color 03 if lr 2,1.color  r 1,2.color then 04 r 1,2.color  (r 1,2.color + 1) (mod 3) 01 P i (i  1, n) 02 lr i-1,i.color  r i-1,i.color 03 r i,i+1.color  lr i-1,i.color 04 lr i+1,i.color  r i+1,i.color 05 if lr i+1,i.color  lr i-1,i.color then 06 r i,i-1.color  lr i+1,i.color 01 P n 02 lr n-1, n.color  r n-1, n.color 03 r n, n -1.color  lr n-1, n.color

7 chapter 8 - Self-Stabilizing Computing7 Self-Stabilization of the algorithm  Lemma 8.1: In every fair execution, P 1 changes the value of r 1,2.color infinitely often  Lemma 8.2: In every fair execution, a configuration is reached in which all the color fields of the communication registers and internal variables have identical values

8 chapter 8 - Self-Stabilizing Computing8 By using these Lemmas (8.1, 8.2) we can see the algorithm works as expected. Once the safe configuration has been achieved, the token will traverse the chain Self-Stabilization of the algorithm

9 chapter 8 - Self-Stabilizing Computing9 A simple running example P 1,C 1 P 2,C 1 P 3,C 2 r 1,2 1 lr 2,1 2 r 3,2 2 lr 2,3 2 r 2,1 1 r 2,3 0 lr 1,2 0 lr 3,2 2 Lets look at a system with three processors that start at a random configuration: C i is the state of the processor (the line in the code it’s about to execute).

10 chapter 8 - Self-Stabilizing Computing10 A simple running example P 1,C 2 P 2,C 1 P 3,C 2 r 1,2 1 lr 2,1 1 r 3,2 2 lr 2,3 2 r 2,1 1 r 2,3 0 lr 1,2 0 lr 3,2 2 P 1 executes line 2: it reads the value of r 2,1 into the local variable lr 2,1.

11 chapter 8 - Self-Stabilizing Computing11 A simple running example P 1,C 2 P 2,C 2 P 3,C 2 r 1,2 1 lr 2,1 1 r 3,2 2 lr 2,3 2 r 2,1 1 r 2,3 1 lr 1,2 1 lr 3,2 2 P 2 executes line 2: it reads the value of r 1,2 into the local variable lr 1,2

12 chapter 8 - Self-Stabilizing Computing12 A simple running example P 1,C 2 P 2,C 3 P 3,C 2 r 1,2 1 lr 2,1 1 r 3,2 2 lr 2,3 2 r 2,1 1 r 2,3 1 lr 1,2 1 lr 3,2 2 P 2 executes line 3: it writes the value of lr 1,2 into r 2,3

13 chapter 8 - Self-Stabilizing Computing13 A simple running example P 1,C 2 P 2,C 4 P 3,C 2 r 1,2 1 lr 2,1 1 r 3,2 2 lr 2,3 2 r 2,1 1 r 2,3 1 lr 1,2 1 lr 3,2 2 P 2 executes line 4: it reads the value of r 3,2 into lr 3,2.Line 6 is not executed since lr 1,2 ≠ lr 3,2.

14 chapter 8 - Self-Stabilizing Computing14 A simple running example P 1,C 2 P 2,C 4 P 3,C 2 r 1,2 1 lr 2,1 1 r 3,2 2 lr 2,3 1 r 2,1 1 r 2,3 1 lr 1,2 1 lr 3,2 2 P 3 executes line 2: it reads the value of r 2,3 into the local variable lr 2,3

15 chapter 8 - Self-Stabilizing Computing15 A simple running example P 1,C 2 P 2,C 4 P 3,C 3 (a full round) r 1,2 1 lr 2,1 1 r 3,2 1 lr 2,3 1 r 2,1 1 r 2,3 1 lr 1,2 1 lr 3,2 2 P 3 executes line 3: it writes the value of lr 2,3 into r 3,2

16 chapter 8 - Self-Stabilizing Computing16 A simple running example P 1,C 2 P 2,C 2-6 P 3,C 1 r 1,2 1 lr 2,1 1 r 3,2 1 lr 2,3 1 r 2,1 1 r 2,3 1 lr 1,2 1 lr 3,2 1 SAFE!!! P 2 executes lines 2-6 and we gate a safe configuration…

17 chapter 8 - Self-Stabilizing Computing17 The Simulation Each processor represents a working tape cell.  The processor’s input represents the initial configuration of the UTM.  The processor’s output represents the UTM’s decision, i.e. output = 1 (0)  UTM accepted (rejected) the input using no more than n working tape cells.

18 chapter 8 - Self-Stabilizing Computing18 The Simulation Each processor maintains 3 local variables: 1. HeadMark i (1-bit) – true if the head is currently on the working tape cell this processor simulates. 2. WorkSymbol i (2-bit) – the current content of the tape cell. 3. Counter i (2-bit) – used to bound the execution of the simulation, and initialize it from time to time. (will be explained soon)

19 chapter 8 - Self-Stabilizing Computing19 The number of configurations  A certain UTM exists, thus the number of states C is bounded by 56 [Hopcroft & Ullman 1979] which possesses:  n memory bits which can contain 2 n different tape contents.  n possibilities for the location of the first ⊥.  n possibilities for the location of the reading head  Thus: cn 2 2 n is the total number of the UTM’s configurations.  Note: for n  14 : 2 2n  cn 2 2 n.  So a UTM execution that exceeds 2 2n steps (configurations) must repeat at least one configuration twice, resulting in an infinite loop.  How to maintain a distributed counter that count up to 2 2n ?

20 chapter 8 - Self-Stabilizing Computing20  All processors maintain a distributed counter using their local variable Counter i.  The system is initialized when counter overflow occurs. (increasing the counter in the following example will end up in initialization) System initialization P3P3 P2P2 P1P1 11 In this example the value of the counter is 63.

21 chapter 8 - Self-Stabilizing Computing21 A Simple Example P3P3 P2P2 P1P1 11 10 Carry:0 Reset:0 I am the token, moving left I am a counter I am a processor MSBLSB Rest is 1  there is an overflow

22 chapter 8 - Self-Stabilizing Computing22 A Simple Example P3P3 P2P2 P1P1 11 10 Carry:0 Reset:0 The start configuration of this example, the token is moving to the left.

23 chapter 8 - Self-Stabilizing Computing23 A Simple Example P3P3 P2P2 P1P1 11 10 Carry:0 Reset:0

24 chapter 8 - Self-Stabilizing Computing24 A Simple Example P3P3 P2P2 P1P1 11 10 Carry:0 Reset:0

25 chapter 8 - Self-Stabilizing Computing25 A Simple Example P3P3 P2P2 P1P1 11 1 Carry:0 Reset:0 P 1 increments the counter without generating a carry

26 chapter 8 - Self-Stabilizing Computing26 A Simple Example P3P3 P2P2 P1P1 11 Carry:0 Reset:0

27 chapter 8 - Self-Stabilizing Computing27 A Simple Example P3P3 P2P2 P1P1 11 Carry:0 Reset:0

28 chapter 8 - Self-Stabilizing Computing28 A Simple Example P3P3 P2P2 P1P1 11 Carry:0 Reset:0

29 chapter 8 - Self-Stabilizing Computing29 A Simple Example P3P3 P2P2 P1P1 11 00 Carry:1 Reset:0 P1 increments the counter which results in generating a carry

30 chapter 8 - Self-Stabilizing Computing30 A Simple Example P3P3 P2P2 P1P1 1100 Carry:1 Reset:0

31 chapter 8 - Self-Stabilizing Computing31 A Simple Example P3P3 P2P2 P1P1 00 Carry:1 Reset:1 P 3 doesn’t have the option to pass on the carry (which means an overflow) and it start a reset.

32 chapter 8 - Self-Stabilizing Computing32 A Simple Example P3P3 P2P2 P1P1 00 Carry:0 Reset:1

33 chapter 8 - Self-Stabilizing Computing33 A Simple Example P3P3 P2P2 P1P1 00 Carry:0 Reset:1 Reset finished, and: HeadMark 1 = true  i ≠ 1:HeadMark i = false

34 chapter 8 - Self-Stabilizing Computing34 The Simulation  When processor P i, with HeadMark i = true, receives the token, it computes the next step, i.e.  WorkSymbol i, State, Right/Left , using: 1. Current state, retrieved from the token. 2. WorkSymbol i. 3. UTM’s transition table.  The head movement is simulated by sending the token to the Right (or Left) neighbor and changing its HeadMark value to be true.  When a processor reaches a decision state it notifies all other to write the correct output.

35 chapter 8 - Self-Stabilizing Computing35 A Simple Example P1P1 P2P2 P3P3 Set head:true state: q 1 HeadMark false Working Cell 0 counter 01 Move head Ø output 0 HeadMark true Working Cell 1 counter 00 Move head Ø output 0 HeadMark false Working Cell 1 counter 00 Move head Ø output 1 I am the token, moving left A token arrives to P 2, with “set head = true”.

36 chapter 8 - Self-Stabilizing Computing36 P 2 consults the UTM transition table, and decides to write 0, and move right. Since the token is moving left now (until it get to the end) P 2 will remember to set the HeadMark when the token returns. A Simple Example P1P1 P2P2 P3P3 HeadMark false Working Cell 0 counter 01 Move head Ø output 0 HeadMark true Working Cell 1 counter 00 Move head R output 0 HeadMark false Working Cell 1 counter 00 Move head Ø output 1

37 chapter 8 - Self-Stabilizing Computing37 A Simple Example P1P1 P2P2 P3P3 Set head:false state: q 26 HeadMark false Working Cell 0 counter1 Move head Ø output 0 HeadMark false Working Cell 0 counter 00 Move head R output 0 HeadMark false Working Cell 1 counter 00 Move head Ø output 1 P 1 is working and increase the counter, but doesn’t calculate a UTM step since the W/R head is not in his cell.

38 chapter 8 - Self-Stabilizing Computing38 A Simple Example P1P1 P2P2 P3P3 Set head:false state: q 26 HeadMark false Working Cell 0 counter 11 Move head Ø output 0 HeadMark false Working Cell 0 counter 00 Move head R output 0 HeadMark false Working Cell 1 counter 00 Move head Ø output 1 P 2 remember that the W/R head should move right so he will change the Set head to be true

39 chapter 8 - Self-Stabilizing Computing39 A Simple Example P1P1 P2P2 P3P3 Set head:true state: q 26 HeadMark false Working Cell 0 counter 11 Move head Ø output 0 HeadMark false Working Cell 0 counter 00 Move head Ø output 0 HeadMark true Working Cell 1 counter 00 Move head Ø output 1

40 chapter 8 - Self-Stabilizing Computing40 Token arrived at P 3, with “set head = true”. P 3 consults the UTM transition table, and decides to write 1 change the state to 32, and move left (note; the token travels left now!). A Simple Example P1P1 P2P2 P3P3 HeadMark false Working Cell 0 counter 11 Move head Ø output 0 HeadMark false Working Cell 0 counter 00 Move head Ø output 0 HeadMark true Working Cell 1 counter 00 Move head L output 1

41 chapter 8 - Self-Stabilizing Computing41 A Simple Example P1P1 P2P2 P3P3 Set head:true state: q 32 HeadMark false Working Cell 0 counter 11 Move head Ø output 0 HeadMark true Working Cell 1 counter 00 Move head Ø output 0 HeadMark false Working Cell 0 counter 00 Move head Ø output 1

42 chapter 8 - Self-Stabilizing Computing42 A Simple Example P1P1 P2P2 P3P3 Set head:true state: q 32 HeadMark false Working Cell 0 counter 11 Move head Ø output 0 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 0

43 chapter 8 - Self-Stabilizing Computing43 A Simple Example P1P1 P2P2 P3P3 HeadMark false Working Cell 0 counter 11 Move head Ø output 0 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 Token arrived at P 2, with “set head = true”. P 2 consults the UTM transition table, and decides to accept. P 2 will place a clear message in the token. HeadMark true Working Cell 1 counter 00 Move head Ø output 0

44 chapter 8 - Self-Stabilizing Computing44 A Simple Example P1P1 P2P2 P3P3 Set head:true state: q accept HeadMark false Working Cell 0 counter 11 Move head Ø output 0 HeadMark true Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1

45 chapter 8 - Self-Stabilizing Computing45 A Simple Example P1P1 P2P2 P3P3 Clear Result:1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1

46 chapter 8 - Self-Stabilizing Computing46 A Simple Example P1P1 P2P2 P3P3 Clear Result:1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1

47 chapter 8 - Self-Stabilizing Computing47 A Simple Example P1P1 P2P2 P3P3 Clear Result:1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1

48 chapter 8 - Self-Stabilizing Computing48 A Simple Example P1P1 P2P2 P3P3 Clear Result:1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1

49 chapter 8 - Self-Stabilizing Computing49 A Simple Example P1P1 P2P2 P3P3 Clear Result:1 HeadMark true Working Cell 0 counter 10 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 HeadMark false Working Cell 0 counter 00 Move head Ø output 1 Now, P 1 will start the computation again.

50 chapter 8 - Self-Stabilizing Computing50 Chapter 8: roadmap 8.1 The Computation Power of Self-Stabilizing Systems 8.2 Queue Machine

51 chapter 8 - Self-Stabilizing Computing51 What is a Queue Machine? A queue machine Q is a finite state machine equipped with a queue. The queue initially contains a non-empty word from ∑ for some (finite) alphabet ∑. In each step of the computation, Q performs: 1) Reads and deletes a letter from the head of the queue. 2) Adds zero or more letters from ∑ to the tail of the queue. 3) Changes a state. The computation terminates when the queue becomes empty. +

52 chapter 8 - Self-Stabilizing Computing52 Token Controller - Definition Token controller is a special type of a queue machine. Assume that the alphabet ∑ contains a subset T of token letters. A queue machine is a token controller if, starting with a non-empty queue of arbitrary content and in an arbitrary state of the finite-state machine, eventually there is exactly 2 different segments, each of them contains exactly one letter from T.

53 chapter 8 - Self-Stabilizing Computing53 Token Controller - Definition The token controller is an abstraction of the token- passing task. The sender is the finite-state machine that receives (finite-length) messages and sends massages in response. The massages in transit form the content of the queue. Token controller messages

54 chapter 8 - Self-Stabilizing Computing54 Does a Token Controller exist ?  The Controller, if exists, cannot compute any estimation of the number of tokens in the queue.  The Controller is finite and the queue may contain any number of messages hence the finite control cannot “remember” what he saw.  The solution: all the information needed is stored within the queue. The controller makes decisions while the messages are passing.

55 chapter 8 - Self-Stabilizing Computing55 Token Controller Algorithm 01 do forever 02 dequeue (color, CounterBit, Token) 03 if color = TokenColor then (*token arrives*) 04 begin 05 if carry = 1 then enqueue (color, 1, false) 06 TokenColor := (color + CounterXor +1)(mod 3) 07 CounterXor := 0 08 carry := 1 09 Token := true 10 end 11 CounterXor := CounterXor  CounterBit 12 NewCounterBit := carry  CounterBit 13 carry := carry  CounterBit 14 enqueue (TokenColor, NewCounterBit, Token) 15 Token := false 16 od

56 chapter 8 - Self-Stabilizing Computing56 Token Controller Algorithm  The algorithm uses three colors to color the messages it sends. TokenColor - the current color.  Each message caries a bit - CounterBit.  A segment of messages is a maximal sequence of messages in the queue with identical color. CounterBit 1 is the first massage who left the controller.  N (segment) - the integer whose binary form is: CounterBit i, CounterBit i -1 … CounterBit 1 N=4 10001 1 1 0111 CounterBit 1 is the least significant bit

57 chapter 8 - Self-Stabilizing Computing57 Token Controller Algorithm While a segment passes, the Controller performs: 1) Change the color of each massage to TokenColor. 2) Calculate XOR (N ( segment ) ). 3) Increments N(segment) by binary addition (using the carry). 4) When a segment with TokenColor arrives calculate the new color.

58 chapter 8 - Self-Stabilizing Computing58 Distributed counter 11001 Token color = 1 Carry = 0 counterXor = 0 … Red = 0 Turquoise= 1 Orange = 2 The current color of the controller The color of the head massage: Color = 1 0 1001 Token color = 2 Carry = 1 counterXor = 1 …

59 chapter 8 - Self-Stabilizing Computing59 Distributed counter (cont) 0 001 Token color = 2 Carry = 1 counterXor = 0 … 0 0 001 Token color = 0 Carry=1 counterXor = 0 01 …

60 chapter 8 - Self-Stabilizing Computing60 Distributed counter (summary) 110100 … Token color = 1 Carry = 1 counterXor = 0 11001 Token color = 1 Carry = 1 counterXor = 0 … Starting at this configuration we will eventually arrived to configuration without green colored massages

61 chapter 8 - Self-Stabilizing Computing61 Distributed counter (summary) 110100 Token color = 1 Carry = 1 counterXor = 0 And we will eventually arrived to configuration with only one color at the messages. 110100 … Token color = 1 Carry = 1 counterXor = 0

62 chapter 8 - Self-Stabilizing Computing62 pseudo-stabilized configuration  When in some configuration c, a message with TokenColor arrives, we say that c is a pseudo- stabilized configuration.  A pseudo-stabilized configuration is a safe configuration when there is only one segment in c.

63 chapter 8 - Self-Stabilizing Computing63 S1S1 S3S3 S2S2 S4S4 The Number of Segments S'1 S3S3S2S2 S4S4 New color = color(S2) The Number of Segments Preserves

64 chapter 8 - Self-Stabilizing Computing64 S1S1 S3S3 S2S2 S4S4 The Number of Segments S1’+S2’ S3S3 S4S4 New color = color(S3) The Number of Segments Reduces

65 chapter 8 - Self-Stabilizing Computing65 Token Controller, is Self- Stabilizing  The colors of the segments in the first pseudo- configuration define the periodic sequence that must be used to preserve the number of segments.  If the sender chooses differently and the number of segments is greater then one, then the number of segments is reduced.  Define Xor(x) as the parity of the binary representation of x.  XorSeq = xor(0), xor(1), xor(2), xor(3)… = 0 1 1 0… is eventually aperiodic (Lemma 8.3).

66 chapter 8 - Self-Stabilizing Computing66 Lemma 8.3: The Infinite Sequence XorSeq is Eventually Aperiodic - proof l and p numbers such that the suffix of XorSeq that follows the first l elements of XorSeq is periodic with period of length p. Case 1 : xor(p) = 1. o Let l 1 = 2 k such that 2 k-1 > l and l 1 > 2p. o xor ( l 1 + p ) = 0, xor ( l 1 ) = 1. o Example: p = 11111, xor ( p ) = 1. l 1 = 1000000, xor ( l 1 ) = 1. xor ( l 1 + p ) = xor ( 1011111 ) = 0 The suffix that follows l has no period p. ll+p l+2p l+3p … l1l1

67 chapter 8 - Self-Stabilizing Computing67 Lemma 8.3 – proof (cont) Case 2 : xor (p) = 0. o Let l 2 = 2 j such that 2 j  p  2 j+1 ( 2 j is the most significant bit of p ). o xor ( p + l 2 ) = xor ( p ) = 0. o xor ( l 1 + p + l 2 ) = 1, while xor ( l 1 + l 2 ) = 0. o Example: p = 11110, xor( p ) = 0. l 1 = 1000000, l 2 = 10000. xor ( p + l 2 ) = xor(101110) = 0. xor ( l 1 + l 2 ) = xor ( 1010000 ) = 0. xor ( l 1 + p + l 2 ) = xor ( 1101110 ) = 1.

68 chapter 8 - Self-Stabilizing Computing68 Token Controller, is Self- Stabilizing Theorem 8.1 : In any execution in which the number of segments in the pseudo-stabilized configuration is fixed, the sequence of colors produced by the algorithm is aperiodic. Proof : o The sequence CounterXor is aperiodic for each segment. o If the combined sequence is periodic then each sequence is periodic. o CounterXor is aperiodic, so the sequence of colors choose by the algorithm is aperiodic.


Download ppt "Chapter 8 - Self-Stabilizing Computing1 Chapter 8 – Self-Stabilizing Computing Self-Stabilization Shlomi Dolev MIT Press, 2000 Draft of January 2004 Shlomi."

Similar presentations


Ads by Google