Leader Election Ch 3 4 1 15 2
- Slides: 42
Leader Election Ch. 3, 4. 1, 15. 2 Chien-Liang Fok 11/25/2020 CS 673 Fall 2003 1
Leader Election process connection n Numerous processes are connected in a digraph One process eventually declares itself leader Motivation: ¨ token ring networks ¨ efficient communication (e. g. , lighthouse routing) 11/25/2020 CS 673 Fall 2003 2
Impossibility Result for Identical processes n Cannot solve leader election problem with identical processes ¨ Proof by induction on the sequence of states ¨ Every process will declare self as leader simultaneously n Solution: Assume identical processes distinguished by a unique identifier (UID) ¨ UID 11/25/2020 is a positive integer CS 673 Fall 2003 3
Synchronous Network All processing done in lock-step formation n There are rounds of computation n Message-passing is done between rounds n 11/25/2020 CS 673 Fall 2003 4
Model 1: Synchronous Ring 1 5 2 4 3 n processes connected in a ring n Processes can distinguish clockwise from counterclockwise neighbor n 11/25/2020 CS 673 Fall 2003 5
Variations on the Theme Non-leaders may have to declare themselves as such n Ring may be unidirectional or bidirectional n Each node may or may not know n, the size of the ring n 11/25/2020 CS 673 Fall 2003 6
LCR Algorithm 1 5 n n n Developed by Le Lann, Chang, and Roberts (1978) Unknown n, unidirectional ring, only leader outputs General idea: 2 4 3 ¨ Every process passes its UID around the ring ¨ Upon reception, compare to own UID n n n 11/25/2020 If larger: Pass to next process If smaller: Discard If equal: Declare self as leader CS 673 Fall 2003 7
LCR Algorithm Proof 1 5 2 4 n n 3 r UIDmax r is the number of rounds Proof by induction on r ¨ After r rounds, the node r away from the Pmax will be sending UIDmax ¨ When r = n, UIDmax will have traveled around the ring 11/25/2020 CS 673 Fall 2003 8
Halting LCR n LCR algorithm never halts ¨ Non-leaders messages n continuously listen for incoming Have leader pass a report message around the ring ¨ This is the general way to transform a non-halting algorithm into a halting one ¨ Transformation Cost: n n 11/25/2020 n additional rounds n additional messages CS 673 Fall 2003 9
LCR Complexity Analysis n Time Complexity: Non-Halting 11/25/2020 Time Communication n 2 n O(n 2) CS 673 Fall 2003 10
HS Algorithm Developed by Hirshberg and Sinclair n Achieves O(n log n) communication complexity, O(n) time complexity n Assumptions: 1 n ¨ Unknown n ¨ Bidirectional ring 5 2 4 11/25/2020 CS 673 Fall 2003 3 11
HS Algorithm (Cont. ) n General idea: 1 5 2 4 ¨ Operate 3 in phases 0, 1, 2, . . . ¨ During phase p, send UID in both directions for a distance of 2 p Processing of received UID same as LCR n If its UID comes back, continue to next round n If it receives its outbound UID, declare self as leader n 11/25/2020 CS 673 Fall 2003 12
Comparison-based Algorithms n LCS and HS are comparison-based algorithms ¨ Only n The communication lower-bound is: Ω(n log n) ¨ See n compare UIDs Lynch section 3. 6 for proof Is this the lower bound in general? 11/25/2020 CS 673 Fall 2003 13
Time. Slice Algorithm Non-comparison-based algorithm n Achieves O(n) communication complexity n Assumptions: n ¨n is known to all processes ¨ Unidirectional communication 11/25/2020 CS 673 Fall 2003 14
Time. Slice Algorithm (Cont. ) n 1 5 General idea: phases 1, 2, 3, . . . ¨ Phase p 2 ¨ Have n n 4 3 Contains n rounds, rounds (p-1)n + 1, …, pn If a node with UID p exists, it is circulated around the ring ¨ If we reach round (p-1)n + 1 and the node with UID = p has not received any UID before, declare self as leader n Process with minimum UID becomes the leader 11/25/2020 CS 673 Fall 2003 15
Time. Slice Algorithm (Cont. ) n Proof foundation: ¨ No messages are sent except between rounds (UIDmin-1) ·n + 1 and UIDmin·n Only n messages are sent n Problem: n ¨ Time complexity is n · UIDmin ¨ Unbounded! 11/25/2020 CS 673 Fall 2003 16
Variable. Speeds Algorithm n n Another non-comparison-based algorithm Does not require knowledge of n Unidirectional links General idea: ¨ Each process sends its UID around the ring ¨ The UID travels one hop every 2 UID rounds ¨ Each process keeps track of lowest UID seen and discards anything higher ¨ If token returns, declare self as leader 11/25/2020 CS 673 Fall 2003 17
Variable. Speeds Algorithm (Cont. ) n Complexity Analysis ¨ Message: 2·n ¨ Time: O(n · 2 Umin) Outrageous unbounded time complexity n This algorithm serves as a counterexample algorithm n Impractical ¨ Shows that impossibility result cannot be proved ¨ 11/25/2020 CS 673 Fall 2003 18
Non-Comparison-based algorithms Can achieve message costs of less than Ω(n log n), but at the cost of unbounded time complexity n With bounded time complexity, the message lower bound for non-comparisonbased algorithms is Ω(n log n) n ¨ See 11/25/2020 Lynch section 3. 7 for proof CS 673 Fall 2003 19
Model 2: General Synch. Network 2 3 1 4 6 5 n processes each with UID n Random connectivity n Strongly connected graph n 11/25/2020 CS 673 Fall 2003 20
Variations on theme Non-leaders may have to declare themselves as such n n may or may not be known n diam may or may not be known n 11/25/2020 CS 673 Fall 2003 21
Flood. Max Algorithm Assume diam is known n General idea: n ¨ Each process remembers the largest UID it has seen ¨ For each round, propagate UIDmax on all outgoing links ¨ After diam rounds, if UIDmax is own UID, declare self as leader 11/25/2020 CS 673 Fall 2003 22
Flood. Max Algorithm (Cont. ) Basically a generalization of LCR n Communication complexity is diam · |E| n ¨ |E| n is the number of outgoing edges Also works if only the upper-bound of diam is known 11/25/2020 CS 673 Fall 2003 23
Flood. Max Algorithm Proof Outline Show that after r rounds, UIDmax has reached all nodes within diameter r of the node with the maximum UID n Claim that when r = diam, all nodes will 2 have received UIDmax 3 n 1 4 6 5 11/25/2020 CS 673 Fall 2003 24
Opt. Flood. Max Algorithm A trivial optimization of Flood. Max n Only broadcast the UIDmax if it changed in the current round n Correctness is obvious, but the proof is not n 11/25/2020 CS 673 Fall 2003 25
Opt. Flood. Max Algorithm Proof n Use the simulation proof method ¨ Formally n Append a new-info flag to each node ¨ Only n relate Opt. Flood. Max to Flood. Max broadcast UIDmax if new-info is true First prove: UIDmax, i > UIDmax, j for any j out-nbrsi, newinfoj must be true ¨ Proof by induction on r ¨ If 11/25/2020 CS 673 Fall 2003 26
Opt. Flood. Max Proof (Cont. ) n To complete the proof, relate the states of Opt. Flood. Max to Flood. Max ¨ Assuming both are started simultaneously, after round r, the states of the two algorithms are the same ¨ Proof by induction on r n See Lynch 4. 1 for proof details 11/25/2020 CS 673 Fall 2003 27
Asynchronous Networks n n n processes connected via reliable FIFO channels Each process distinguished by UID Processes do not operate in lock-step formation Use I/O Automata to model processes and channels ¨ Action 11/25/2020 of Pi include sendi, receivei, and leaderi CS 673 Fall 2003 28
Model 3: Asynchronous Ring 1 n processes arranged in a ring 5 n May be bidirectional or unidirectional 4 3 n n may or may not be known n Clockwise neighbor can be distinguished from counterclockwise neighbor n 11/25/2020 CS 673 Fall 2003 2 29
Asynchronous LCR algorithm n Same as synchronous LCR algorithm except: ¨ Send buffer of each process must be able to hold up to n messages n This algorithm is intuitively correct, but the proof is complex ¨ Do not know where UIDmax is ¨ Cannot relate location of UIDmax to the round 11/25/2020 CS 673 Fall 2003 30
Asynchronous LCR Proof n Proof outline ¨ Show that for 0 ≤ r ≤ n-1, eventually UIDmax appears in the buffer sendimax+r n Proof by induction on r ¨ Show that UIDmax will eventually appear on channel connecting to the input of imax 11/25/2020 CS 673 Fall 2003 31
Asynchronous HS Algorithm n The synchronous HS algorithm can also be trivially modified to work in asynchronous rings ¨ Just make sure all channels can handle message pileups 11/25/2020 CS 673 Fall 2003 32
Peterson Algorithm Requires O(n log n) messages n Unidirectional links n Unknown n n Relies on asynchronously determined phases n Elects an arbitrary process as the leader n 11/25/2020 CS 673 Fall 2003 33
Peterson Algorithm (Cont. ) n n Process can be in active or relay mode In the first phase, all nodes send their UID two hops clockwise If UID of immediate counter-clockwise neighbor is highest of the three, adopt it as its new UID and remain active ¨ Otherwise, enter relay mode ¨ n n In the following phases, active node sends their new UID to their two clock-wise active neighbors and repeat If an active node sees that its immediate counterclockwise active neighbor has the same UID, declare self as leader 11/25/2020 CS 673 Fall 2003 34
Peterson Algorithm Examples Leader! 1 2 4 3 7 9 8 5 11/25/2020 4 Leader! 8 9 9 CS 673 Fall 2003 35
Peterson Algorithm Time Cost n In each phase, the number of active processes is decreased by two ¨ O(log n n) phases For each phase p, the first p phases complete in O(pn(l+d)) ¨l = upperbound on time to process message ¨ d = upperbound on output queue delay n Thus, the time cost is O(n log n (l+d)) 11/25/2020 CS 673 Fall 2003 36
Peterson Algorithm Message Cost There at most log n + 1 phases n During each phase, each process sends at most two messages (2 n messages) n Message cost = O(n log n) n 11/25/2020 CS 673 Fall 2003 37
Communication Lower Bound n The communication lower bound of asynchronous comparison-based algorithms is Ω(n log n) ¨ Synchronous rings is a restriction on asynchronous rings ¨ See Lynch section 15. 1. 4 for proof 11/25/2020 CS 673 Fall 2003 38
Model 4: Asynchronous General n 2 Assumptions: 1 links ¨ Random links 6 ¨ Strongly connected graph ¨ Identical processes except UID 3 ¨ Bidirectional 11/25/2020 CS 673 Fall 2003 4 5 39
Asynchronous Flood. Max Since there are no rounds, Flood. Max cannot be trivially extended to asynch. Networks n Workaround: n ¨ Append round number to each message ¨ Each node collects all incoming round messages before processing them 11/25/2020 CS 673 Fall 2003 40
Alternative techniques n There are many other general asynch. network protocols that use: ¨ Spanning Tree, Convergecast, and Broadcast ¨ Synchronizers to simulate synchronous networks ¨ Consistent snapshots for termination detection 11/25/2020 CS 673 Fall 2003 41
Conclusions There are many leader election protocols n Special protocols exist for ring networks n Algorithms for asynchronous networks are more complicated n 11/25/2020 CS 673 Fall 2003 42
- Le problem?
- Transformational vs transformative leadership
- Abraham lincoln's election
- Economic protest parties definition
- 1932 presidential election
- Election of 1896
- Election day political cartoon
- Election of 1860 pie chart
- Clarity election night reporting
- What problems did this election underscore adams
- Strip seal in election
- Xxxx20
- Lincolns election
- George caleb bingham the county election
- Cobra election form sample
- Electoral machine
- Dcrc full form in election
- 1796 election
- Which phrase best defines a mountain range?
- Monroe doctrine cartoon meaning
- The election of 1800 showed that
- Thomas county election results
- Election of 1824
- The election process in the bahamas
- British election study
- Brainpop presidential election
- Universicum
- Cfdt safran
- Esuchi
- Maysville veto
- Fdr election map
- Lincolns election date
- Application for election duty certificate
- 1932 presidential election
- Election monitoring dashboard
- Commodore matthew perry apush
- 1960 election
- Election of 1860 definition
- What factors affect voter behavior
- Arizona multistate service provider election
- Election of 1824
- Leader doer thinker carer
- Mission statement for portfolio