Skip to content
SEE Exam Prep

Question 7 of 15 · CIE-1 QB · 7 marks

Open in ChatGPT

Explain the Ring Election algorithm with a suitable diagram and example.


Introduction

An election algorithm chooses one process to act as coordinator when the current coordinator fails, and it must do so without a human and without every process deciding separately. The ring algorithm assumes the processes are arranged in a logical ring and each process knows only its successor.

Algorithm

  1. When a process notices the coordinator has failed, it sends an election message (election, id, ) to its successor containing its own id and an empty list.
  2. Each process that receives the message adds its own id to the list and forwards it to its successor.
  3. When the message returns to the initiator, the initiator sees its own id already in the list, so the list has made one full circle.
  4. The initiator changes the message to coordinator (coordinator, highest-id) and sends it round the ring again.
  5. Every process receives the coordinator message and records the highest id as the new coordinator; the process with that id knows it is the coordinator.
  6. A process may start an election only if it is not already running one, so simultaneous elections merge into one thereby.

Diagram

P2P5P7

Example

  • Processes 2, 5 and 7 form a ring and the coordinator 7 fails.
  • Process 2 starts an election: the message travels 2 → 5 → 7, collecting [2, 5, 7].
  • Returning to 2, the highest id is 7, but 7 has failed.
  • In the variant that skips the failed process, the highest reachable id, 5, becomes coordinator.

Complexity

  • Messages: 2n in the worst case, one election round plus one coordinator round.
  • Time: O(n), one full traversal.

Advantages and limitations

  • Simple to implement and every process learns the result.
  • It needs a logical ring, which must be rebuilt whenever a process leaves.
  • A single failed link splits the ring unless membership is repaired.
  • It always sends 2n messages even when the highest id is known early, so it wastes messages compared with the bully algorithm.

Conclusion

The ring algorithm is a clean, message-linear election for static membership, and its cost is paid every time a coordinator changes.