05b Elections Slides
05b Elections Slides
Week 5: Part 2
Leader Election
• Assumptions
– Processes have no distinguishing characteristics
– Each process has a unique ID to identify itself
– Reliable message delivery
P0 P1 P2 P3 P4 P5
DEAD
hello?
Suppose P5 dies
P0 P1 P2 P3 P4 P5
DEAD
ELECTION
ELECTION
P2 starts an election
P0 P1 P2 P3 P4 P5
DEAD
ELECTION
ELECTION
P0 P1 P2 P3 P4 P5
DEAD
ELECTION
P0 P1 P2 P3 P4 P5
Leader = P4
DEAD
Nobody responds to P4
P5
DEAD
P4 P0
P3 P1
Election: {P1}
P2
P5
DEAD
P4 P0
P3 P1
P2
Election: {P1, P2}
P5
DEAD
P4 P0
P3 P1
P2
P3 P1
P2
P3 P1
P2
P5
DEAD
P4 P0
Election: {P1, P2, P3, P4, P0}
P3 P1
P2
P5
DEAD
P4 P0
This is me! Winner!
P5
DEAD
P4 P0
P4
Many other election
P4 algorithms that target
P4
other topologies: mesh,
P4
P3 P1 torus, hypercube, trees, …
P4
P2
If PID(message) < PID(process) AND process is not a participant – we are a higher ID number; use it
replace PID in message with PID(process) and forward the new message
set the process state to participant
If PID(message) == PID(process)
the process is now the leader
– message fully circulated to the one who started: announce winner