0% found this document useful (0 votes)
19 views14 pages

Election - Algorithms DCL - 5

The document outlines the study and implementation of election algorithms, specifically the Ring and Bully algorithms, used to elect a coordinator process among distributed nodes. It describes the communication methods, types of messages, and the assumptions required for the election process, as well as the time complexity of each algorithm. The Ring algorithm involves a logical ring structure for message passing, while the Bully algorithm focuses on nodes with higher identifiers initiating elections.

Uploaded by

Eshan Jinabade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views14 pages

Election - Algorithms DCL - 5

The document outlines the study and implementation of election algorithms, specifically the Ring and Bully algorithms, used to elect a coordinator process among distributed nodes. It describes the communication methods, types of messages, and the assumptions required for the election process, as well as the time complexity of each algorithm. The Ring algorithm involves a logical ring structure for message passing, while the Bully algorithm focuses on nodes with higher identifiers initiating elections.

Uploaded by

Eshan Jinabade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

BTech - CSE [ 2022 - 23 ]

Distributed Computing Lab


Assignment - 5

Title : Election Algorithms

Aim : To study and implement the following :-


1. Ring Algorithm
2. Bully AlgorithmElection Algorithms

02/26/25 1
Election Algorithms
• There is a collection of processes/nodes that are identified by a
unique number
• A connection is established amongst the processes/nodes,hence
these can communicate with each other.Sending and Receiving
happens between these processes.
• A coordinator(leader) process needes to be elected through the
election algorithms
• And The coordinator election is done through election algorithms

02/26/25 2
Why elect a coordinator process ?

• A coordinator process can be a decision maker eg In banking,a


coordinator can decide which server shall respond to transactions
• A coordinator can be a resourse allocator
• A coordinator can be responsible for task divisions for distributed
computing

02/26/25 3
Types of messages

There are basically 3 types of messages :

1. An election message to initiate the election

2. A reply/response message given in response to the


election message

3. A coordinator message sent to inform other processes,


the id of the coordinator process.
02/26/25 4
Election Algorithm :
Assumptions/Requirements
1. Any process can call for an election.
2. A process can call for at most one election at a time.
3. Multiple processes can call an election simultaneously.
4. The result of an election should not depend on which process calls for it.
5.Each process has
Variable called elected
An attribute value called attr, e.g., id, MAC address, CPU

6.The non-faulty process with the best (highest) election attribute value (e.g., highest id or
address, or fastest cpu, etc.) is elected.
7. Requirement: A run (execution) of the election algorithm must always guarantee at the end:
a) safety and b) liveliness [ non-faulty process]

02/26/25 5
Ring algorithm

02/26/25 6
Ring Algorithm : Progress

Ring of N processes
33
17

24

15

28 24

Note: The election was started by process 17.


The highest process identifier encountered so far is 24.
(final leader will be 33)
7
Ring Algorithm : Time Complexity

(attr:=id)
1.The worst-case scenario occurs when the counter-clockwise neighbor has the highest attr/id
2. A total of N-1 messages is required to reach the new coordinator-to-be.
3.Another N messages are required until the new coordinator-to-be ensures it is the new coordinator.
4.Another N messages are required to circulate the elected messages.
worst case : 3N-1
best : 2N

assume : one process began election


ALTERNATIVELY :-
In ring algorithm, on the contrary, irrespective of which process detects the failure of coordinator and initiates
an election, an election always requires 2(n-1) messages. (n-1) messages needed for one round rotation of the
ELECTION message, and another (n-1) messages for the COORDINATOR message.

02/26/25 8
Modified Ring Algorithm

1.Processes are organized in a logical ring.


2.Any process that discovers the coordinator (leader) has failed initiates an “election”
message. This is the initiator of the election.
3.The message is circulated around the ring, bypassing failed nodes.
4.Each node adds (appends) its id:attr to the message as it passes it to the next node.
5.Once the message gets to the initiator, it elects the node with the best election attribute
value.
6.It then sends a “coordinator” message with the id of the newly-elected coordinator. Again,
each node adds (appends) its id to the end of the message.
Once “coordinator” message gets back to initiator,
election is over if “coordinator” is in id-list.
else the algorithm is repeated (handles election failure).
Bully Algorithm

1.A node initiates election by sending an “election” message to only nodes that have a higher id
than itself.
If no answer, announce itself to lower nodes as coordinator.
if any answer, then there is some higher node active; wait for coordinator message. If none received after time
out, start a new election.

2.A node that receives an “election” message replies with answer, & starts an election – unless
it has already.

3. When a process finds the coordinator has failed, if it knows its id is the highest, it elects itself
as coordinator, then sends a coordinator message to all processes with lower identifiers.
Bully Algorithm : Progress

1.P sends an ELECTION message to all processes with


higher numbers.

2.If no one responds, P wins the election and becomes


coordinator.

3.If one of the higher-ups answers, it takes over. P’s job is


done.
02/26/25 11
The Bully Algorithm (1)

Figure 6-20. The bully election algorithm. (a) Process 4 holds an


election. (b) Processes 5 and 6 respond, telling 4 to stop.
02/26/25
(c) Now 5 and 6 each hold an election. 12
The Bully Algorithm (2)

Figure 6-20. The bully election algorithm. (d) Process 6 tells 5 to stop. (e) Process 6
02/26/25 wins and tells everyone. 13
Bully Algorithm : Time Complexity
• In the worst case,the bully algorithm requires O(n2) messages. When
the process having the priority number just below the failed
coordinator detects failure of coordinator, it immediately elects itself
as the coordinator and sends n-2 coordinator messages.

• (n-1) messages in the best case.

02/26/25 14

You might also like