Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-1 Chapter 4: roadmap 4.1 Token Passing: Converting a Central Daemon to read/write 4.2 Data-Link.

Similar presentations


Presentation on theme: "Chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-1 Chapter 4: roadmap 4.1 Token Passing: Converting a Central Daemon to read/write 4.2 Data-Link."— Presentation transcript:

1 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-1 Chapter 4: roadmap 4.1 Token Passing: Converting a Central Daemon to read/write 4.2 Data-Link Algorithms: Converting Shared Memory to Message Passing 4.3 Self-Stabilizing Ranking: Converting an Id-based System to a Special-processor System 4.4 Update: Converting a Special Processor to an Id-based Dynamic System 4.5 Stabilizing Synchronizers: Converting Synchronous to Asynchronous Algorithms 4.6 Self-Stabilizing Naming in Uniform Systems: Converting Id-based to Uniform Dynamic Systems

2 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-2 Motivation  Question: can the tasks achieved in Id-based systems also be achieved in a uniform dynamic system?  Answer: No!  For example: Algorithm for Leader Election (in a uniform system, possible only by using randomization).  We are going to present a randomized self- stabilizing leader-election and naming algorithm for dynamic systems.  The algorithm stabilizes within O(d) cycles.

3 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-3 Naming  Given any communication graph, with up to N identical processors we want to find a unique Id for each processor  At first, each processor has an arbitrary Id  By coloring the tree, we know if it is unique. If so, we’re done. Otherwise, the processor has to find a new Id  The idea of the propagation is similar to the Update Algorithm  Each processor chooses an Id and notifies all others by building a spanning tree  In our algorithm, an Id which already exists, will be replaced with a new one

4 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-4 Formalization  Each processor P i has a table with at most N rows  This table is called: Processors i  Each row represents the state of the processor in another tree, rooted at any other processor (we have N such processors)  Each processor also has a queue, Queue i, with at most N 2 rows, that should have been in the Processors i table but there is no space for them there  Each row contains: {tid, dis, f, color, ackclr, ot, ack, list, del}

5 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-5 Formalization (Cont.) Where:  tid is an identifier of a root of a tree (range: between 0 to N 10 ).  dis is the distance of P i from the root of this tree  f is a pointer to the parent of P i in the tree.  color is used to identify other trees with the same tid (range: between 0 to N 10 ).  ackclr is a boolean variable, and used by P i to acknowledge to its parent that its color is known by all processors under P i.

6 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-6 Cont.  ot is a boolean variable, and used by P i to notify the parent of the existence of another tree with the same tid.  ack is also a boolean variable, and used to notify the parent of P i of the termination of the propagation of its new identifier.  list and del may contain up to N identifiers.  list is used by P i to report to its parent the identifiers of the processors in its subtree.  del is used by P i to notify its children in the tree of conflicting identifiers.

7 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-7 The Coloring - finding double Ids example of one tree, rooted at a specific P. X X X We want to ensure that no two processors have the same chosen identifier. Each processor repeatedly colors its tree with a randomly chosen color. Consider a tree T with tid=x. Whenever a processor P i notices that all its children have its color, and their ackclr field is true, P i randomly chooses a new color. Each non-root processor P j repeatedly copies the color of its parent. If the color is new, P j assigns false to its ackclr field. Whenever P j reads that all its children have the same color as its own, and all their ackclr field is true, P j assigns true to its ackclr field. The colors are chosen from a large range. Hence, there is a very high probability, that when a processor P i chooses a new color, the color is new in the tree. Whenever a processor P j changes its color from y to z, P j checks whether it has a neighbor which belongs to a tree T’ rooted at processor with tid=x and with a color different from y and z. If so, P j concludes that more than a single root of a tree with tid=x exists, and set the value of ot field to true. T’ T

8 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-8 The update part  Processor P i chooses a new Id  P i notifies its children about its new Id, they notify their children, etc.  Thus, we actually build a spanning BFS tree  When getting to a leaf, the leaf acknowledges to its parent that it got the message  Each processor P j which gets acknowledgements from all its children, sends an acknowledgement to its parent  When the root, P i, gets acknowledgements from all its children, it knows that everyone knows its Id

9 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-9 Cont.  All notifications between processors, are tuples with  {tid, dis, f, color, ackclr, ot, ack, list, del}  where each field contains the appropriate data it wants its neighbors to see.

10 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-10 The Algorithm  Each processor Pi reads the tables of its neighbors, over and over  ReadSeti is the union of the tuples Pi read from its neighbors  In each row of ReadSeti, Pi sets the value of the f field to be the appropriate neighbor. The value of the dis field is incremented by 1  Pi adds a tuple with its own Id and dis=0

11 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-11 Cont.  For every tid=x, Pi removes every tuple with tid=x which does not have the minimal value in the dis field  Pi sorts the remaining tuples in ReadSet i by the value of their dis fields. If there are more than N tuples left in ReadSet i, Pi assigns the first N tuples to Processors i and the rest are enqueued in Queue i

12 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-12 But, this does not mean that there are no two trees with identical Ids!! P j modifies the value of the fields: f, dis, ack and list. f – the new father – k. dis – the old dis + 1 ack – true if: 1. P j ‘s neighbors have same tid and dis+1. 2. P j ‘s children on tree have P j ‘s dis+1 and also have ack=true. What if there are two processors with the same Id? – First solution X X X Each processor P j participates in the propagation of information with feedback from every other processor, including P i. When a processor P j includes for the first time a tuple t k with tid=x from a neighbor P k, P j copies the value of the tuple fields of t k to the corresponding fields of t j. The list field of P j contains the names of all the processors in the subtree rooted at P j Thus, when the root gets acknowledgements from all its children, it gets also the list of all the processors in the tree. Now it can see if there are two identical Ids, and propagate to its children the list of those Ids, in the del field. PiPi PjPj PkPk example of one tree, rooted at a specific P.

13 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-13 What if there are two processors with the same Id? – Second solution  Each root colors its tree as we saw in the coloring part  If it finds out that its Id is not unique, it chooses a new one, and we start from the beginning…

14 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-14 Why does it work?  The range of the Ids is very big (till N 10 )  If a processor found out that another processor has the same Id, then it chooses a new one  The choice is made by luck, from the scheduler-luck game.  The probability of choosing an existing identifier is negligible. But, it could be that the result of the random function is not identical to luck’s choice in the game (the new Id already appears in the system)  In such a case, we start the algorithm from the beginning, with the arbitrary configuration we have Thus, every processor selects a new identifier no more than once.

15 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-15 The reason for the Queue table  When a processor P i chooses a new identifier, a tuple with tid= ID i and dis= 0 is repeatedly written in Processors i.  This action starts the construction of the spanning tree rooted in P i that is identified by tid= ID i.  Still, tuples with the previous identifier of P i may be present in Processors variables.  Thus, since the number of tuples in each Processors variable is bounded, it is unclear whether every processor can include the new tuple in its Processors variable.

16 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-16 The Queue table – cont.  A processor that chooses a new identifier leaves floating tuples with small distances in the system.  These tuples compete with entries of the Processors variables.  Thus, it is possible that part of the tree will be disconnected, not participating in the coloring process, and thus cause a false other-trees indication.  To overcome such a scenario, each processor maintains a queue.

17 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-17 The Queue  When each processor chooses an identifier no more than once, the number of distinct identifiers present in the Processors variables during the entire execution is no greater than N+N 2.  Therefore, it is possible to use a queue of N 2 entries to ensure that, once a tuple with a specific identifier is included in Processors i, a tuple with this identifier exists in either Processors i or Queue i.  Whenever P i computes a new value for Processors i, it deletes from Queue i every tuple with the same tid (keeps only the minimal tid). Thus, there are no two rows with an identical tid value in Queue i.

18 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-18 Correctness  Lemma: In any given configuration, the number of distinct identifiers is less than N 8  Proof: Each tuple may contain no more than 2N+1 distinct identifiers (in tid, list and del). The number of tuples in Processors i and in Queue i is at most N+N 2. Furthermore, each processor P i maintains two internal variables for each neighbor. Thus, the total number of distinct identifiers is no greater than (2N+1)(N+N 2 )N 1)

19 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-19 Correctness – cont.  Lemma: The probability that every identifier- choose operation, in a sequence of N identifier- choose operations, results in a nonexistent identifier is greater than ½  Proof: The probability that a single identifier choose operation results in a nonexistent identifier is at least (1 - n 8 /n 10 ) = (1 - 1/n 2 ). And (1 - 1/n 2 ) N > ½ for a sequence of N choose operations (N > 1)

20 chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-20 Correctness – cont.  Theorem: A safe configuration is reached in an expected O(d) cycles  Outline of proof: The combined probability of the scheduler-luck game is greater than ½, and the expected number of cycles of the execution of the game is O(d) (like in the update algorithm)


Download ppt "Chapter 4 - Self-Stabilizing Algorithms for Model Conservation4-1 Chapter 4: roadmap 4.1 Token Passing: Converting a Central Daemon to read/write 4.2 Data-Link."

Similar presentations


Ads by Google