Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Bully Algorithm example to reflect the scenario where each process starts an election if

it notices that the coordinator has failed, and the election message is forwarded to the
process with the next highest priority until it reaches the highest priority process, which
becomes the new coordinator.

Bully Algorithm (Extended):

Assume P1 has the highest priority and P5 has the lowest priority.

1. Process P1 detects that the coordinator (highest priority) has failed.


2. P1 starts an election by sending an election message to all processes with higher
priorities (P2, P3, P4, P5).
3. P2, having a higher priority, acknowledges the election message and starts its own
election by sending messages to processes with higher priorities (P3, P4, P5).
4. P3, having a higher priority, acknowledges the election message and starts its own
election by sending messages to processes with higher priorities (P4, P5).
5. P4, having a higher priority, acknowledges the election message and starts its own
election by sending a message to the only process with a higher priority (P5).
6. P5, being the process with the highest priority and not finding any higher priority
process, declares itself as the new coordinator.
7. P5 broadcasts a coordinator message to all processes.
8. All processes recognize P5 as the new coordinator.

In this scenario, the election process cascades through processes with higher priorities
until it reaches the highest priority process, which then becomes the new coordinator.

Ring Algorithm example to reflect the scenario where P1 sends an election message to
P2, then P2 forwards the election message to P3, and so on until it reaches P5, which
doesn't find any process with a higher ID and becomes the new coordinator.

Ring Algorithm (Extended):

1. Process P1 detects that the leader has failed.


2. P1 initiates an election by sending an election message to its successor, P2.
3. P2 compares its ID with the received election message. Since P2 has a higher ID, it
forwards the election message to its successor, P3.
4. P3, having a higher ID, forwards the election message to its successor, P4.
5. P4, having a higher ID, forwards the election message to its successor, P5.
6. P5 doesn't find any process with a higher ID, so it declares itself as the new coordinator.
7. P5 sends a coordinator message to P1, informing it of the new leader.
8. P1 receives the coordinator message and acknowledges P5 as the new leader.
9. The election process ends.

This scenario demonstrates how the election message circulates through the ring until it
reaches the highest-ID process, which then becomes the coordinator.

You might also like