1 / 142

Selecting leader in a clique in O (n log n) By Pierre A.Humblet

Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms , Technion. Problem background. Arbitrary non empty subset wake up spontaneously ans start executing common asynchronous distributed algorithm. 5. 17. 4. 3. 1. 2.

yestin
Download Presentation

Selecting leader in a clique in O (n log n) By Pierre A.Humblet

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms , Technion

  2. Problem background Arbitrary non empty subset wake up spontaneously ans start executing common asynchronous distributed algorithm 5 17 4 3 1 2 1 2 19 2 3 67 4

  3. Assumption Messages arrive without error after an arbitrary but finite delay

  4. The algorithm Main idea : as long as a node did not surrender he tries to capture other nodes according to the edges. First he tries to capture the node at the end point of edge #1, then #2 and so on. 5 17 4 3 1 2 1 2 19 2 3 67 4

  5. 5 wants to capture 17 1. TEST: I want to capture you! 3. Master, 5 want to have a fight 17 5 17 4. Lets have a fight: 5 vs 17 2. Let me ask my master

  6. 5 wants to capture 17 1. TEST: I want to capture you! 3. Master, 5 want to have a fight 17 5 17 4. Lets have a fight: 5 vs 17 2. Let me ask my master 5. Answer to the fight 6. If 5 won- tell him

  7. Wake up call A: B: WINNER(A)

  8. Wake up call A: STATE:activeSIZE:0MASTER:A B: STATE:activeSIZE:0MASTER:B WINNER(A) STATE is active\stopped. Active means he was not captured yetSIZE is the size of my kingdom MASTER is the identity of my master

  9. A process the message of type “WINNER” A: STATE:activeSIZE:0MASTER:A B: STATE:activeSIZE:0MASTER:B WINNER(A) If ID=id (yes) if state='active' then SIZE=SIZE+1 If SIZE=N stop if STATE='active' then send TEST(SIZE,ID) on edge SIZE

  10. A process the message of type “WINNER” A: STATE:activeSIZE:1MASTER:A B: STATE:activeSIZE:0MASTER:B WINNER(A) If ID=id (yes) if state='active' then SIZE=SIZE+1if SIZE=N stop! if STATE='active' then send TEST(SIZE,ID) on edge SIZE

  11. A process the message of type “WINNER” A: STATE:activeSIZE:1MASTER:A B: STATE:activeSIZE:0MASTER:B WINNER(A) If ID=id (yes) if state='active' then SIZE=SIZE+1 if SIZE=N stop! if STATE='active' then send TEST(SIZE,ID) on edge SIZE

  12. A process the message of type “WINNER” A: STATE:activeSIZE:1MASTER:A B: STATE:activeSIZE:0MASTER:B TEST(1,A) WINNER(A) If ID=id (yes) If STATE='active' then SIZE=SIZE+1 If SIZE=N stop if STATE='active' thenSend TEST(SIZE,ID) on edge SIZE

  13. B process the message of type “TEST” on edge 1 A: STATE:activeSIZE:1MASTER:A B: STATE:activeSIZE:0MASTER:B EDGE_TO(MASTER)= -1 TEST(1,A) WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET

  14. B process the message of type “TEST” on edge 1 A: STATE:activeSIZE:1MASTER:A B: STATE:activeSIZE:0MASTER:B EDGE_TO(MASTER)=-1EDGE_TO(A)=1 TEST(1,A) WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e \\{not in our domain, tell the master} PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET

  15. B process the message of type “TEST” on edge 1 A: STATE:activeSIZE:1MASTER:A B: STATE:activeSIZE:0MASTER:B EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1 TEST(1,A) WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=ePENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET PENDING is the number of messages I received but did not finished responding

  16. B process the message of type “TEST” on edge 1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1 A: STATE:activeSIZE:1MASTER:A B: STATE:activeSIZE:0MASTER:B TEST(1,A) WINNER(A) TEST(1,A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET

  17. B process the message of type “TEST” on edge -1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1 A: STATE:activeSIZE:1MASTER:A B: STATE:activeSIZE:0MASTER:B TEST(1,A) WINNER(A) TEST(1,A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET

  18. B process the message of type “TEST” on edge -1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1 A: STATE:activeSIZE:1MASTER:A B: STATE:stoppedSIZE:0MASTER:B TEST(1,A) WINNER(A) TEST(1,A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SETelse \\(e<SIZE) If (size,id) > (SIZE,ID) then STATE='stopped' send WINNER(id) on edge e

  19. B process the message of type “TEST” on edge -1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1 A: STATE:activeSIZE:1MASTER:A B: STATE:stoppedSIZE:0MASTER:B TEST(1,A) WINNER(A) TEST(1,A)WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SETelse \\(e<SIZE) If (size,id) > (SIZE,ID) then \\if (1,A) > (0,B) YES!!!! lexicographic order STATE='stopped' send WINNER(id) on edge e

  20. B process the message of type “WINNER(A)” on edge -1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1 A: STATE:activeSIZE:1MASTER:A B: STATE:stoppedSIZE:0MASTER:A TEST(1,A) WINNER(A) TEST(1,A)WINNER(A) If ID=idElse If MASTER <> id //if B<>A MASTER=id send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then ..

  21. B process the message of type “WINNER(A)” on edge -1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1 A: STATE:activeSIZE:1MASTER:A B: STATE:stoppedSIZE:0MASTER:A TEST(1,A) WINNER(A) WINNER(A) TEST(1,A)WINNER(A) If ID=idElse If MASTER <> id //if B<>A MASTER=id send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then ..

  22. B process the message of type “WINNER(A)” on edge -1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=1-1=0 A: STATE:activeSIZE:1MASTER:A B: STATE:stoppedSIZE:0MASTER:A TEST(1,A) WINNER(A) WINNER(A) TEST(1,A)WINNER(A) If ID=idElse If MASTER <> id //if B<>A send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then ..

  23. A process the message of type “WINNER(A)” on edge 1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=1-1=0 A: STATE:activeSIZE:1MASTER:A B: STATE:stoppedSIZE:0MASTER:A TEST(1,A) WINNER(A) WINNER(A) TEST(1,A)WINNER(A) If ID=idElse If MASTER <> id //if B<>A send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then ..

  24. A process the message of type “WINNER(A)” on edge 1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=1-1=0 A: STATE:activeSIZE:2MASTER:A B: STATE:stoppedSIZE:0MASTER:A TEST(1,A) WINNER(A) WINNER(A) TEST(1,A)WINNER(A) If ID=id \\ if A=A if STATE='active then SIZE=SIZE+1 if SIZE=N then STOPElse If MASTER <> id //if B<>A send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then ..

  25. A process the message of type “WINNER(A)” on edge 1 EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=1-1=0 A: STATE:activeSIZE:1MASTER:A B: STATE:stoppedSIZE:0MASTER:A TEST(1,A) WINNER(A) WINNER(A) TEST(1,A)WINNER(A) If ID=id \\ if A=A if STATE='active then SIZE=SIZE+1 if SIZE=N then STOP – you are the leader!!!!!!!!!!Else If MASTER <> id //if B<>A send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then ..

  26. The algorithm When node ID receive WINNER(id) :if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER)

  27. The algorithm When node ID receive TEST(size,id) on edge e: if e < SIZE then//message comes from our domain if (size,id) > (SIZE,ID) then //lexicographic STATE='stopped' send WINNER(id) on edge e else send WINNER(ID) on edge eelse //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 if PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

  28. Example A: B: WINNER(A) D: WINNER(D) C: E: WINNER(C) F F G H I J

  29. A<B<C<D<... A: B: WINNER(A) D: WINNER(D) C: E: WINNER(C) F F G H I J

  30. A if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A: B: WINNER(A) D: WINNER(D) C: E: WINNER(C) F F G H I J

  31. A if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A: B: WINNER(A) D: WINNER(D) C: E: WINNER(C) F F G H I J

  32. A TEST(1,A) if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop!If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A: B: WINNER(A) D: WINNER(D) C: E: WINNER(C) F F G H I J

  33. C if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop!If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A: B: WINNER(A) D: WINNER(D) TEST(1,C) C: E: WINNER(C) F F G H I J

  34. B-process A's message If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET TEST(1,A) A: B: WINNER(A) D: WINNER(D) C: E: WINNER(C) F F G H I J

  35. B-process C's message(1,C) If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET A: B: WINNER(A) D: WINNER(D) C: E: WINNER(C) F F G H I J

  36. B-process B's message (test(1,A)) If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET A: B: WINNER(A) D: WINNER(D) C: E: WINNER(C) F F G H I J

  37. B-process B's message (test(1,A)) If e < SIZE //message comes from our If (size,id) > (SIZE,ID) then //lexicographicSTATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e A: B: WINNER(A) D: WINNER(A) WINNER(D) C: E: WINNER(C) F F G H I J

  38. B-process B's message WINNER(A) • if ID=id then • ELSE if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 • if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) WINNER(A) A: B: WINNER(A) D: TEST(1,C) WINNER(D) C: E: WINNER(C) F F G H I J

  39. A-process B's message WINNER(A) • if ID=id then • if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A: B: D: TEST(2,A) C: E: F F G H I J

  40. A-process B's message TEST(1,C) If e < SIZE //message comes from our domain If (size,id) > (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e A: B: D: WINNER(A) C: E: F F G H I J

  41. B-process A's message WINNER(A) • if ID=id then • else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 • if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) A: B: D: C: E: F F G H I J

  42. C-process A's message TEST(2,A) If e < SIZEElse //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) Else put TEST(size,id) in PENDING_SET A: B: D: C: E: F F G TEST(2,A) H I J

  43. C-process C's message TEST(2,A) If e < SIZE //message comes from our domain If (size,id) > (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e A: B: D: C: E: F F G WINNER(A) H I J

  44. C-process C's message WINNER(A) if ID=id then else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) A: B: D: WINNER(A) C: E: F F G H I J

  45. A-process C's message WINNER(A) • if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A: B: D: TEST(3,A) C: E: F F G H I J

  46. D-process awake WINNER(D) • if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A: B: D: TEST(1,D) C: E: F F G H I J

  47. D-process A message TEST(3,A) If e < SIZEElse //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET A: B: D: TEST(3,A) C: E: F F G H I J

  48. D-process D message TEST(3,A) If e < SIZE //message comes from our domain If (size,id) > (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e A: B: D: WINNER(A) C: E: F F G H I J

  49. D-process D message WINNER(A) if ID=id then else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) A: B: D: WINNER(A) C: E: F F G H I J

  50. A-process D message WINNER(A) • if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A: B: D: TEST(4,A) C: E: F F G H I J

More Related