Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Leader Election Algorithms in Synchronous Ring Networks

Similar presentations


Presentation on theme: "Distributed Leader Election Algorithms in Synchronous Ring Networks"— Presentation transcript:

1 Distributed Leader Election Algorithms in Synchronous Ring Networks
Valia Mitsou National Technical University of Athens

2 Distributed Computing
Distributed computing is decentralised and parallel computing, where two or more processors communicate over a network to accomplish a common task. The collaborating processors are often identical. One of the central problems is…

3 Leader Election Given a network of processors, exactly one processor should output the decision that it is the leader. It is usually required that all non-leader processors are informed of the leader’s election. Βοηθάει στο να σπάει η συμμετρία και να μπορούμε να τρέχουμε centralized αλγόριθμους σε decentralized network.

4 The Synchronous Network Model

5 Network representation
Directed Graph G(V,E), |V|= n Nodes represent processors Edges represent (directed) communication channels Message Passing System Global Clock (for every tic a step of the algorithm is executed)

6 Processor’s fields Every processor consists of the following:
statesi (a not necessarily finite set of states) starti (the initial state) msgsi (a message generation function) transi (a state transition function) Κάθε επεξεργαστής αποτελείται από τα εξής πεδία: Ένα σύνολο καταστάσεων από το οποίο επιλέγει την τρέχουσα κατάστασή του κάθε φορά, δηλαδή τι τιμές θα έχουν κάθε στιγμή της οι μεταβλητές που θα χρησιμοποιήσει για την εκτέλεση του αλγόρίθμου. Η αρχική του κατάσταση είναι μια από το σύνολο καταστάσεων με την οποία ξεκινά την εκτέλεση (πώς αρχικοποιούνται οι μεταβλητές που χρησιμοποιεί) Μια γεννήτρια συνάρτηση μηνυμάτων βάσει της οποίας παράγει τα μηνύματα που θα στείλει στους γείτονές του Μια συνάρτηση μετάβασης καταστάσεων βάσει της οποίας θα υπολογίσει τη νέα κατάσταση, δηλαδή θα αλλάξει τιμές στις μεταβλητές.

7 Step Apply the message generation function to the current state to generate the messages to be sent to all outgoing neighbors. Apply the state transition function to the current state and the incoming messages to obtain the new state. Η εκτέλεση ξεκινά με όλους τους επεξεργαστές να βρίσκονται σε κάποια initial state. Μετά οι επεξεργαστές κάνουν τα ακόλουθα δύο πράγματα: Σύμφωνα με την κατάσταση που βρίσκονται υπολογίζουν το μήνυμα που θα στείλουν στους γείτονές τους και το στέλνουν Έπειτα ανάλογα με την τρέχουσα κατάστασή τους και τα μηνύματα που θα λάβουν υπολογίζουν την καινούρια κατάστασή τους. Αυτά αποτελούν ένα βήμα Ο κατανεμημένος υπολογισμός αποτελείται από κάποιο αριθμό τέτοιων βημάτων.

8 Complexity measures Time complexity: the number of the steps until all outputs are produced or all the processors halt. Communication complexity: the number of non-null messages that are sent during the execution. Αυτό που μας ενδιαφέρει κυρίως είναι το time αρκεί να μην επιβαρύνεται τόσο πολύ το σύστημα που να επιβραδύνεται η διαδικασία

9 Leader Election in Rings with UIDs

10 Setting The network graph is a directed ring consisting of n nodes (n is unknown to the processors). Processors run the same deterministic algorithm. The only piece of information supplied to the processors is a unique integer identifier (UID). Οι διαδικασίες είναι ακίνητες πάνω στους κόμβους και τρέχουν όλες ταυτόχρονα τον ίδιο ντετερμινιστικό αλγόριθμο. Αν το n είναι γνωστό τότε οι διαδικασίες μπορούν να το χρησιμοποιήσουν στα προγράμματα τους. Εκτός αυτού οι διαδικασίες έχουν και περιορισμένη δύναμη, δηλαδή μπορούν μόνο να στέλνουν κάποια μηνύματα στους out_nbrs που να περιέχουν περιορισμένη πληροφορία (το uid και ίσως και κάποιου είδους μετρητές ή διακριτικά) και να δέχονται τέτοια μηνύματα απο τους in_nbrs. Επίσης μπορούν να εκτελούν συγκρίσεις και ίσως και κάποιου είδους υπολογισμούς βάσει των οποίων θα αποφασίσουν αν θα στείλουν μήνυμα στις επόμενες διαδικασίες. Θα αποδείξουμε στη συνέχεια ότι αν οι διαικασίες ήταν πανομοιότυπες τότε θα ήταν αδύνατη η εκλογή αρχηγού, αφού δε θα είχαν κανένα στοιχείο που να τις ξεχωρίζει μεταξύ τους

11 Related Work and Important Results
Algorithm Time Complexity Msg Complexity LCR (‘79) O(n) O(n2) HS (’80) O(nlogn) Our Algorithm O(nlogn) (better constant) Lower bound Ω(n) (trivial) Ω(nlogn) FL (’87) Franklin, Dolev- Klawe- Rodeh, Peterson, δικός μου

12 Our Algorithm

13 Basic Idea Every processor starts by sending a message with its UID
Nodes which receive a UID greater than their own take on the task of forwarding it around the ring, while the node which initially possessed it becomes inactive. The processor that will become the leader is the one with the greatest UID and this will happen when its UID returns to itself after traveling around the ring.

14 Description Every processor has the following fields: Its own UID
The greatest UID it has seen so far One activity field {active, inactive, waiting} One status field {leader, unknown}

15 Description The algorithm is executed in phases 0, 1, 2...
Every phase k has two parts

16 First Part of Phase k Every active processor i sends a token with the greatest UID it has seen so far to travel for distance at most 2k.

17 First Part of Phase k When a processor receives a UID that is equal to its own UID, it declares itself the leader. If this is not the case then it compares it with the greatest UID it has seen so far.

18 First Part of Phase k If the incoming UID is smaller then it discards it. If the incoming UID is greater then It saves this UID as the greatest it has seen so far. Either it becomes waiting if it is the incoming UID’s end of path (it has already traveled distance 2k), or it passes it to the next processor and becomes inactive.

19 Second Part of Phase k After this time (2k), if i is still active resends the UID to travel distance 2k and becomes inactive. If a waiting processor receives again the same UID after 2k time then it becomes active. If not it becomes inactive. The next phase k+1 begins…

20 A Simple Example

21 4 7 2 5 2 4 7 5

22 4 7 2 5 2 4 7 5

23 4 7 2 5 2 2 4 5 4 7 7 5

24 4 7 2 5 2 5 4 5 4 7 7 7

25 4 7 2 5 5 4 7 7

26 4 7 2 5 5 4 4 7 7 7

27 4 2 5 4 4 7 7 5 7 7

28 A More Complicated Example

29 5 3 4 2 6 8 1 7 7 5 1 3 4 8 6 2

30 5 3 4 2 6 8 1 7 7 5 1 Phase 0 Part 1 Step 1 3 4 8 6 2

31 5 3 4 2 6 8 1 7 7 5 1 3 4 8 6 2

32 5 3 4 2 6 8 1 7 1 7 7 5 1 3 5 3 4 6 8 4 2 8 6 2

33 5 3 4 2 6 8 1 7 1 7 7 5 7 3 5 6 5 6 8 4 2 8 8 4

34 5 3 4 2 6 8 1 7 7 5 7 Phase 0 Part 2 Step 1 6 5 8 8 4

35 5 3 4 2 6 8 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8 8 8 8 7 8 7 8 7

61 5 3 4 2 6 8 1 7 8 8 8 Phase 2 Part 1 Step 3 8 7 8 8 7

62 5 3 4 2 6 8 1 7 8 8 8 8 7 8 8 7

63 5 3 4 2 6 8 1 7 8 8 8 8 8 7 8 8 7

64 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8 7

65 5 3 4 2 6 8 1 7 8 8 8 Phase 2 Part 1 Step 4 8 8 8 8 7

66 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 7

67 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8 7

68 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8 8

69 5 3 4 2 6 8 1 7 8 8 8 Phase 2 Part 2 Step 1 8 8 8 8 8

70 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8

71 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8

72 5 3 4 2 6 8 1 7 8 8 8 Phase 2 Part 2 Step 2 8 8 8 8 8

73 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8

74 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8

75 5 3 4 2 6 8 1 7 8 8 8 Phase 2 Part 2 Step 3 8 8 8 8 8

76 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8

77 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8

78 5 3 4 2 6 8 1 7 8 8 8 Phase 2 Part 2 Step 4 8 8 8 8 8

79 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8

80 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8 8

81 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8 8

82 5 3 4 2 6 8 1 7 8 8 8 Phase 3 Part 1 Step 1 8 8 8 8 8

83 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8

84 5 3 4 2 6 8 1 7 8 8 8 8 8 8 8 8 8

85 5 1 7 8 8 8 3 8 8 4 8 8 2 8 6 8 8

86 Complexity Analysis

87 Execution Time Total running time = time until maximum UID reaches its initiator (one round = n steps) But how many phases will be executed until maxUID reaches its initiator?

88 5 1 7 3 4 2 8 8 6

89 5 1 7 3 4 8 2 8 6

90 5 1 7 8 3 4 2 8 6

91 5 1 7 3 4 8 2 8 6

92 5 1 7 3 4 2 8 8 6

93 Number of Phases f = total number of phases.
… + 2f-1 < n → 2f – 1 < n 2f+1 – 1 ≥ n So f ≈ logn

94 Time Complexity In every phase i: 2 parts 2i steps each part
Total running time … + 2f + rest ≤ ≤ 2f+2 – 2 = O(2logn) = = O(n) 2i+1 steps

95 Messages Only an active processor can initiate a message.
Inactive processors pass the message to the final receiver

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111 2i+1

112 In phase i+1 2i+1 → 1 active processor
n → (n / 2i+1) active processors Every active processor causes 2∙2i+1= 2i+2 messages to be sent. Total number of messages in this phase: (n / 2i+1) ∙ 2i+2 ≈ 4n

113 Message Complexity Total number of phases ≈ logn
Number of messages in every phase ≈ 4n The total number of messages during the execution is O(nlogn) with a constant factor 4 (improving a previous constant factor 8 in HS).

114 Complexity Time Complexity: O(n) Message Complexity: O(nlogn)
For non-leader results we need n extra steps and n extra messages.

115 THANK YOU!

116 Leader Election in Anonymous Rings

117 General Lemma: If the network is symmetric (i.e. a ring) and anonymous (the processors haven’t UIDs) then it is impossible to elect a leader by a deterministic algorithm. [by Angluin (1980)] Probabilistic algorithms are used to break symmetry.

118 Itai and Rodeh Algorithm
Assumption: processors know n. The Algorithm The algorithm proceeds in phases, each of them containing n steps. At every phase, a ≤ n processors are active (initially everyone). During each phase some processors may become inactive. At the beginning of every phase, every active processor decides with probability a-1 whether or not to become a candidate. To do that, it picks a random number r, 0<r<1 and if r<a-1, then it becomes a candidate and initiates a pebble to travel around the ring. Αυτός το Ένας προηγούμενός τους αλγόριθμος 1981, στηρίζεται στον αλγόριθμο LCR

119 Itai and Rodeh Algorithm
To compute the number of candidates (c), each processor counts the pebbles it has seen. Number of pebbles counted = Number of candidates. At the end of the phase, every processor has calculated c. If c=1 then sole candidate becomes leader. If c>1 then a new phase begins with the new active processors (the candidates of the previous phase). If c=0 the phase was useless.

120 Itai and Rodeh Algorithm
0.46 0.04 a-1 = 1/10 c = 2 0.37 0.35 0.83 0.64 0.08 0.22 0.53 0.93

121 Itai and Rodeh Algorithm
Useless phase 0.74 a-1 = 1/2 c = 2 0.88

122 Itai and Rodeh Algorithm
0.32 a-1 = 1/2 c = 1 0.69

123 Itai and Rodeh Algorithm
The leader!!!

124 Itai and Rodeh Algorithm- Complexity Analysis
p(a,c) : the probability that c out of a active processors become candidates. Then Proof: Xi a random variable, Xi=1 if i becomes a candidate, else 0 (bernoulli trial) Then X=ΣnXi= the number of processors become candidates. X~binomial distribution. Thus

125 Itai and Rodeh Algorithm- Complexity Analysis
Average Case Time Complexity: · n Message Complexity: · n The number of pebbles initialized per phase is X (the number of active processors that become candidates). E[X ] = E[ΣaXi ] = Σa(E[Xi ]) = a · a-1 = 1 Thus, the expected message complexity per phase is n. Για n τείνει στο άπειρο το L = σταθερό Ο αριθμός αυτός διαισθητικά είναι σταθερός επειδή το Ε[Χ] = 1 Bit Complxity ίδια! Σημαντική βελτίωση από τον προηγούμενό τους αλγόριθμο ο οποίος ήταν O(nlogn)

126 Itai and Rodeh Algorithm- Complexity Analysis
Theorem: The expected number of phases required to reduce the number of active processors from a to 1 l(a) converges to … Proof sketch:

127 Itai and Rodeh Algorithm- Complexity Analysis
For fixed c, L(a,c) converges, L( ,c) converges, . Thus, So, L ≈

128 Itai and Rodeh Algorithm- Complexity Analysis
Average Case Time Complexity: · n Message Complexity: · n The number of pebbles initialized per phase is X (the number of active processors that become candidates). E[X ] = E[ΣaXi ] = Σa(E[Xi ]) = a · a-1 = 1 Thus, the expected message complexity per phase is n.


Download ppt "Distributed Leader Election Algorithms in Synchronous Ring Networks"

Similar presentations


Ads by Google