Election Algorithm: Bully
Election Algorithms
• Choosing a coordinator site.
• Coordinator generally distributes work, takes care of a failed site etc.
• The coordinator is to be elected.
• Every site has an unique id.
• Higher the id higher the precedence to be elected as a coordinator.
Bully Election Algorithm
When is it invoked?
Election starts when the old coordinator no longer responds
to the requests of the sites.
Who starts it?
Any process who notices that coordinator is not responding.
Example
Bully Election Algorithm
Process
1. Site S sends an ELECTION message to all processes with higher numbers.
2. If no one responds, S wins the election and becomes a coordinator.
3. If one of the higher ups answers , it takes over. P’s job is done.
4. When a site receives an ELECTION message from lower numbered site, it sends an OK message, saying that
he is alive and will take over.
5. Eventually, all but one takes over and announces himself to be the COORDINATOR, with coordinator
message.
Lab Expt :
Input:
Number of sites
Priority(optional)
Initiator site
Output: Simulate the algorithm
Number of messages
• Election
• OR
• Coordinator