Leader election in synchronous ring
A network graph of nodes 1 to n clock wise, Nodes do not need to know about their or neighbors numbers, But they are able to distinguish about clock wise and anti clock wise neighbors
Problem is selecting unique leader among themselves
Types of problems
- Ring can be uni-directional or bi-directional
- Number of nodes(n) can be known or unknown
- Processes can be identical or can be distinguished by UID
Identical Processes
Theorem : Let be a system of processes, , arranged in a bidirectional ring. If all the processes in are identical, then does not solve the leader-election problem.
Intuition : By symmetry, what one does, so do the others
Cannot find leader in identical process because of symmetry, To break symmetry, one solution is UID's
LCR Algorithm
- Assumes only unidirectional ring
- Does not rely on knowing the size of the ring
- Only the leader performs output
- Uses comparisons on UIDs ()
Each process sends its identifier around the ring. When a process receives an incoming identifier, it compares that identifier to its own.
- If the incoming identifier is greater than its own, it keeps passing the identifier.
- If it is less than its own, it discards the incoming identifier.
- If it is equal to its own, the process declares itself the leader.
Fromally
= set of UIDs
- , initially
- , initially
consists of the single state defined by the given initializations.
send the current value of send to
send := null
if the incoming messsage is v, then
v > u: send := v
v = u: status := leader
v < u: do nothing
Output after rounds
- Process outputs leader by the end of round .
Halting
We can modify above algorithm by allowing the elected leader to initiate a special report message to be sent around the ring. Any process that receives the report message can halt, after passing it on and set itself as non-leader
Complexity analysis
Time complexity - Communication complexity -
HS Algorithm
- Assumes bidirectional ring
- Does not rely on knowing the size of the ring
- Only the leader performs output
- Uses comparisons on UIDs ()
Processes operate in phases . In each phase, processes send token with UID in both directions. Tokens in phase intend to travel and turn back to sender
- If a received UID is greater than self UID, it is relayed on
- If it is smaller, it is discarded
- If it is equal, the process outputs leader
Formally
is the set of triples consisting of a UID, a flag value in , and a positive integer .
- of type UID, initially 's UID
- , initially 's UID, out, 1
- , initially 's UID, out, 1
- , initially
- non negative integer, initially 0
consists of the single state defined by the given initializations.
- send the current value of to
- send the current value of to
send+ := null
send- := null
if the message from i-1 is (v, out, h) then
v > u and h > 1: send+ := (v, out, h-1)
v > u and h = 1: send- := (v, in, 1)
v = u: status := leader
if the message from i+1 is (v, out, h) then
v > u and h > 1: send- := (v, out, h-1)
v > u and h = 1: send+ := (v, in, 1)
v = u: status := leader
if the message from i-1 is (v, in, 1) and v != u then
send+ := (v, in, 1)
if the message from i-1 is (v, in, 1) and v != u then
send- := (v, in, 1)
if the messages from i-1 or i+1 is (u, in, 1) then
phase := phase + 1
send+ := (u, out, 2**phase)
send- := (u, out, 2**phase)
Complexity analysis
Check out the book provided below
Correctness
- A process with UID only outputs leader when a message started at travels the whole ring and arrives back at .
- At most one process can become leader: the one with the maximum UID.