Pag 140-144
Election Algorithms
<aside>
💡 Election Algorithms
- One process has to act as a coordinator. It doesn’t matter which process is
- If the coordinator goes does, an election must be taken
- We assume that every process knows the process number of every other process. What the process do not know is which one are currently up and which ones are currently down.
- In general, the highest numbered process is the winner of the election.
- The goal of the election algorithm is to ensure that when an election starts, it concludes with all processes agreeing on who the new coordinator is to be
</aside>

Bully Algorithm
<aside>
💡 When a process $P$ detects the coordinator is no longer responding to requests it hold an election as follows
- $P$ sends an ELECTION message to all processes with higher numbers (every process has a unique process number)
- If no one responds, $P$ wins the election and becomes coordinator
- If one of the higher-ups answers, it takes over. $P$’s job is done
- Each higher-ups process sends ELECTION message to all processes with higher numbers until one of them wins.
- The winner announces it’s the coordinator by sending a COORDINATOR message to all running processes.

In case the original coordinator comes back, it hold an election. It’s called bully algorithm because the process with the highest process number always wins.
</aside>



Ring Algorithm
<aside>
💡 Ring algorithm
- Each process knows who the successor is.
- When a process notices the coordinator is not responding, it holds an election.
- The election message goes around the ring and when a process does not respond, the senders skips it.
- At each step the sender adds its own process number to the list in the message
- When the election message arrives to the original sender (the process that started the election) the process with the highest process number is elected.
- Afterwards the original process sends a COORDINATOR message around the ring informing everyone who the coordinator process is and who the members of the new ring are.

</aside>

