# Election Algorithms

#### Election Algorithms

- The
**coordinator election problem**is to choose a process from among a group of processes on different processors in a distributed system to act as the central coordinator. - An
**election algorithm**is an algorithm for solving the coordinator election problem. By the nature of the coordinator election problem, any election algorithm must be a distributed algorithm.

-a group of processes on different machines need to choose a coordinator

-peer to peer communication: every process can send messages to every other process.

-Assume that processes have unique IDs, such that one is highest

-Assume that the priority of process *P _{i}* is

*i*

There mainly following election algorithms:-

- Bully Election
- Token Ring Election

**A. Bully Algorithm**

A.1. Implement the Bully algorithm to elect a leader for threads

A.2. Provide 7 Solaris kernel threads T1,T2,T3,T4,T5,T6,T7 such that :T7 is the leader and finishes execution (dies) and T5 is the first thread that finds out.

A.3. Show that threads cooperate to find the new leader.

**B. Ring Algorithm**

B.1. Implement the Ring Algorithm to elect a leader for threads

B.2. Provide 7 Solaris kernel threads T1,T2,T3,T4,T5,T6,T7 in a ring

such that :

T7 is the leader and finishes execution (dies) and T3 is the first

thread that finds out.

B.3. Show that threads cooperate to find the new leader.