Distributed Algorithms (22903) - PowerPoint PPT Presentation

About This Presentation
Title:

Distributed Algorithms (22903)

Description:

No fixed upper bound on the delay of a message or the time ... In every execution, exactly one process enters an elected. state, all others enter a non ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 19
Provided by: maurice90
Category:

less

Transcript and Presenter's Notes

Title: Distributed Algorithms (22903)


1
DistributedAlgorithms (22903)
Leader election in rings
  • Lecturer Danny Hendler

This presentation is based on the book
Distributed Computing by Hagit attiya
Jennifer Welch
2
Message-passing systems
p3
p1
p0
1
1
1
2
3
2
2
1
p2
  • Processes are represented by graph nodes.
  • Bi-directional (unless otherwise stated) labeled
    communication links
  • Each process pi (having r links) has state
    consisting of
  • Program state
  • inbutim, 1 m r
  • outbufim, 1 m r (this is inaccessible to
    pi)

3
Message-passing systems (contd)
p3
p1
p0
1
1
1
2
3
2
2
1
p2
  • A Configuration is a vector of process states
    (q0, , qn-1)
  • In the initial configuration
  • inbuf buffers are empty
  • outbuf buffers may contain messages

4
Synchronous message-passing systems
p3
p1
p0
1
1
1
2
3
2
2
1
p2
  • Computation proceeds in rounds
  • In each round
  • All messages in the outbuf buffers are delivered
  • Each process performs a computational step and
    sends at most a single message on every link.

5
Asynchronous message-passing systems
p3
p1
p0
1
1
1
2
3
2
2
1
p2
  • No fixed upper bound on the delay of a message
    or the time between computation steps
  • An execution is a sequence of events
  • comp(i) a computational step by process i
  • del(i,j,m) the delivery of message m from pi
    to pj

6
Leader Election in Rings
p0
1
2
1
2
p1
p2
2
1
  • Each process has to decide whether it is a
    leader or not
  • Termination states are partitioned to elected
    and not-elected.
  • In every execution, exactly one process enters
    an elected state, all others enter a
    non-elected state.
  • We assume rings are oriented.

7
Leader election in anonymous rings
p
1
2
1
2
p
p
2
1
  • A ring algorithm is anonymous if processes dont
    have an ID they can use in the algorithm (all
    perform the same code)

An anonymous leader election algorithm is
Impossible!!
8
A simple algorithm for (non-anonymous)
asynchronous rings
  1. Each process sends probe(ID) to its left neighbor
    (and then waits)
  2. Upon receiving a message probe(i) (from the
    right)
  3. if (i gt ID)
  4. forward message to the left
  5. if (iID)
  6. send terminate(ID) and terminate as
    leader
  7. Upon receiving terminate(i)
  8. if (i gt ID)
  9. forward message to the left and terminate
    as non-leader

T(n2)
Message complexity is
9
A more efficient asynchronous leader election
algorithm
  • Proceeds in phases
  • In phase j, a process tries to become the
    temporary leader of its 2j-neighborhood
  • Only temporary leaders of phase-j continue to
    phase j1

10
A more effieicnt asynchronous leader election
algorithm (contd)
  1. Intially, asleeptrue
  2. Upon receiving no message (spontaneous wakeup)
  3. if (asleep)
  4. asleepfalse
  5. send probe(ID, 0, 1) to left and right
  6. Upon receiving probe(j,l,d) from left (resp.,
    right)
  7. if (jid) terminate as leader
  8. if (jgtid) and (dlt2l) send probe(j,l,d1) to
    right (resp., left)
  9. if (jgtid) and (d 2l) send reply(j,l) to
    left (resp. right)
  10. Upon receiving reply(j,l) from left (resp.,
    right)
  11. if (j ? id) send reply(j,l) to right (resp.,
    left)
  12. else
  13. if already received reply(j,l) from right
    (resp. left)
  14. send probe(ID,l1,1) to left and right

11
The complexity of the asynchronous leader
election algorithm is n log n
12
An (n log n) lower bound on the number of messages
A ring algorithm is uniform if it has no
knowledge of the size of the ring. It is
non-uniform if it can use its knowledge about the
size of the ring.
Well see a proof for uniform algorithms where
the process with the maximum ID must be elected
and all other processes must learn its ID (write
it to some local variable).
13
Pasting R1 and R2 into R(illustration 1. for
Lemma 6)
p1
p2
e2
R2
R1
e1
q2
q1
p1
p2
ep
R2
R1
eq
q2
q1
14
Induction step of lower bound(illustration 2.
for Lemma 6)
P
p1
p2
ep
R2
R1
eq
q2
q1
Q
15
An O(n) messages Non-uniform Algorithm for
Synchronous Rings
  1. Initially phase0 and round 0
  2. if (phase ID)
  3. send Leader(ID)
  4. terminate as leader
  5. else
  6. roundround1
  7. if (round n)
  8. phasephase1
  9. round0
  10. Upon receiving Leader(j)
  11. if (round lt n-1)
  12. send Leader(j)
  13. terminate as non-leader
  • Synchronized start
  • Only clockwise links are used

Time complexity?
n(minID1)
16
An O(n) messages Uniform Algorithm
  • Does not rely on synchronized start a
    preliminary wake-up phase is added.
  • Processes that do note wake-up spontaneously
    act as relays
  • Messages from process with ID i travel at
    speed 1/2i (here we assume IDs are
    non-negative)

17
An O(n) messages uniform Algorithm (contd)
  • Initially waiting is empty and asleep is true
  • Let R be the set of messages received in this
    computation round
  • S empty set Set of IDs to send
  • if (asleep) then
  • asleepfalse
  • if R is emtpy
  • min ID Participating
  • add ID to S
  • Else min 8 Act as a relay
  • for each lt m gt in R do
  • if (m lt min)
  • become not elected
  • add lt m gt to waiting and remember when lt m
    gt was added
  • min m
  • if (m ID) become elected
  • for each lt m gt in waiting do
  • if lt m gt was received 2m-1 rounds ago
  • remove lt m gt from waiting and add to S

18
A proof that the algorithm has linear complexity
Write a Comment
User Comments (0)
About PowerShow.com