Mutual Exclusion and Election Algorithms
3. Response time, measured by the interval a process issues a request and the process exits the CS
4.3 Token-based Solutions
4.4.1 Chang and Roberts’ algorithm
The following is an election algorithm for processes interconnected as a unidirectional ring proposed by Chang and Roberts [9] which uses the principle of selective extinction and requires only O(n log n) messages with n as the number of processes. It is a generalization of an algorithm proposed by LeLann [28].
In the algorithm n processes are arranged in any order around the ring. We assume that all the process
ids are distinct and the smallest one has the highest priority. Whenever P
i receives an election message (an identifier of a process), it compares this message with its own identifier id(i) and transmits the smaller one to its neighbor along the counter-clockwise direction or the clockwise direction. When P
i
receives its own identifier, it becomes the coordinator and informs all the others by sending out the id of the elected process.
Parameters in each process P
i: id(i): cons;
participant: var Boolean (F);
coordinator: var integer;
Chang and Roberts’ algorithm:
election-algorithm ::= || P(i : 0..n - 1)
It is obvious that the algorithm picks one and only one number - the smallest identifier of all the processes. The time required to select a coordinator is between two and three turnaround times on the ring. It is clear that the number of transmissions of the message with type elected is n. To calculate the number of transmissions of the message with type election, we first consider two extreme cases. One case is that election is initiated by a process with a maximum value. The election message travels exactly one round and it terminates at the initiator. The number of message transfers is O(n). The other case (the least favorable) corresponds to the situation where the processes are arranged in decreasing
order and each process initiates an election simultaneously. The message then issued by P
i undergoes i + 1 transfers so that the total number of messages is
or O(n2)
In general, let P(i, k) be the probability that the message i is transferred k times (or k - 1 neighbors of P
i
have identifiers that are less than i, but the kth neighbor’s identifier is greater than i). Clearly,
The message carrying the number n is transferred n times; the mean number of transfers from that of number i is
and, therefore, the mean total number is
which can be shown [9] to be O(n log n). Note that the above complexity is in the average case not in the worst case.
Franklin [16] proposed an algorithm with a complexity of O(n log n) in the worst case. However, it is assumed that the ring network is bidirectional. Initially each process is active and it compares its id with ids from two neighboring active processes in both directions. If it is a local minimum of three ids, it remains active; otherwise, it becomes passive. After each round only half of the participating processes will survive. Therefore, a total of log n rounds is needed. Note that when a process becomes passive, it will not participate in the subsequent comparison but it will still forward incoming ids. This algorithm has been extended in [15] and [35] to a unidirectional ring network with the same message complexity.
It has been shown that O(n log n) is a lower bound for comparison-based algorithms. We will show later that this bound can be improved using non-comparison-based algorithms.
Previous Table of Contents Next
Copyright © CRC Press LLC
Previous Table of Contents Next
4.4.1.1 Garcia-Molina’s bully algorithm
The bully algorithm [17] is a reliable election algorithm for a system where each process knows the priority of all other processes. Again, the process with the highest priority level is elected. It is assumed that a process can fail and recover at any time. The recovered process forces all processes with lower priorities to let it become the coordinator if there is no other active process with a higher priority.
Whenever a process P detects a failure of a coordinator through a timeout, it broadcasts an election message to all processes with a higher priority and waits for a reply from one of the higher priority processes. If no response is received within a time limit, it is assumed that all these processes fail, and P declares itself the new coordinator and broadcasts its id to all processes with a lower priority. If a
response is received within the time limit, process P sets up another timeout to receive the id of the new coordinator. Either the id of the new coordinator is received within the new time limit or nothing is received and process P resends the election message.
For a process with a higher priority number than P receiving the request it responds to P and begins its own election algorithm by sending an election message to all processes with a higher priority. If this process itself has the highest priority, it can declare itself the winner immediately.
In general, election is usually performed only if there is a system failure; therefore, failure detection and handling is normally an integral part of the election algorithm. The bully algorithm can be easily
extended to include a reliable failure detector under a synchronous system, i.e., the time for a message delivery and the time for a node to respond are known a priori. A more realistic algorithm, called invitation algorithm [17], is based on the asynchronous model but it is much more complex than the bully algorithm.
There are many other reliable (or resilient) mutual exclusion and election algorithms. One reliable mutual exclusion algorithm uses a token and it checks whether the token is lost during network failure and regenerates it if necessary. Three types of network failures: PE failure, communication controller failure, and communication link failure can be tolerated by using a timeout mechanism. In [25] King et al. provided a reliable election algorithm which can tolerate both fail-stop and Byzantine type faults (a malicious type of fault to be discussed in Chapter 8).