distributed leader election algorithms in synchronous ring networks valia mitsou national technical...

113
Distributed Leader Election Algorithms in Synchronous Ring Networks Valia Mitsou National Technical University of Athens

Upload: tyler-catchpole

Post on 11-Dec-2015

218 views

Category:

Documents


0 download

TRANSCRIPT

Distributed Leader Election Algorithms in

Synchronous Ring Networks

Valia Mitsou

National Technical University of Athens

Distributed Computing

Distributed computing is decentralised and parallel computing, where two or more processors communicate over a network to accomplish a common task.

The collaborating processors are often identical. One of the central problems is…

Leader Election

Given a network of processors, exactly one processor should output the

decision that it is the leader.

It is usually required that all non-leader processors are informed of the leader’s election.

The Synchronous Network Model

Network representation

• Directed Graph G(V,E), |V|= n• Nodes represent processors• Edges represent (directed)

communication channels• Message Passing System• Global Clock (for every tic a step

of the algorithm is executed)

Complexity measures

• Time complexity: the number of the steps until all outputs are produced or all the processors halt.

• Communication complexity: the number of non-null messages that are sent during the execution.

Leader Election in Rings with UIDs

Setting• The network graph is a directed

ring consisting of n nodes (n is unknown to the processors).

• Processors run the same deterministic algorithm.

• The only piece of information supplied to the processors is a unique integer identifier (UID).

Related Work and Important Results

Algorithm Time Complexity

Msg Complexity

LCR (‘79) O(n) O(n2)

HS (’80) O(n) O(nlogn)

Our Algorithm O(n) O(nlogn) (better constant)

Lower bound Ω(n) (trivial) Ω(nlogn) FL (’87)

Our Algorithm

Basic Idea• Every processor starts by sending a

message with its UID

• Nodes which receive a UID greater than their own take on the task of forwarding it around the ring, while the node which initially possessed it becomes inactive.

• The processor that will become the leader is the one with the greatest UID and this will happen when its UID returns to itself after traveling around the ring.

Description

Every processor has the following fields:• Its own UID• The greatest UID it has seen so far• One activity field {active, inactive,

waiting}• One status field {leader, unknown}

Description

• The algorithm is executed in phases 0, 1, 2...

• Every phase k has two parts

First Part of Phase k

Every active processor i sends a token with the greatest UID it has seen so far to travel for distance at most 2k.

First Part of Phase k

When a processor receives a UID that is equal to its own UID, it declares itself the leader.

If this is not the case then it compares it with the greatest UID it has seen so far.

First Part of Phase k

• If the incoming UID is smaller then it discards it.

• If the incoming UID is greater then– It saves this UID as the greatest it has seen so

far.– Either it becomes waiting if it is the incoming

UID’s end of path (it has already traveled distance 2k), or it passes it to the next processor and becomes inactive.

Second Part of Phase k

After this time (2k), if i is still active resends the UID to travel distance 2k and becomes inactive.

• If a waiting processor receives again the same UID after 2k time then it becomes active.

• If not it becomes inactive.

The next phase k+1 begins…

A Simple Example

A More Complicated Example

Complexity Analysis

Execution Time

Total running time = time until maximum UID reaches its initiator (one round = n steps)

But how many phases will be executed until maxUID reaches its initiator?

Number of Phases

• f = total number of phases.• 1 + 2 + 4 + … + 2f-1 < n → 2f – 1 < n• 2f+1 – 1 ≥ n• So f ≈ logn

Time Complexity

In every phase i:• 2 parts• 2i steps each part

Total running time2 + 4 + 8 + … + 2f + rest ≤ ≤ 2f+2 – 2 = O(2logn) = = O(n)

2i+1 steps

Messages

• Only an active processor can initiate a message.

• Inactive processors pass the message to the final receiver

2i+1

In phase i+1

2i+1 → 1 active processorn → (n / 2i+1) active processors

• Every active processor causes 2∙2i+1= 2i+2 messages to be sent.

• Total number of messages in this phase:

(n / 2i+1) ∙ 2i+2 ≈ 4n

Message Complexity

• Total number of phases ≈ logn• Number of messages in every

phase ≈ 4n

The total number of messages during the execution is O(nlogn) with a constant factor 4 (improving a previous constant factor 8 in HS).

Complexity

• Time Complexity: O(n)• Message Complexity: O(nlogn)

For non-leader results we need n extra steps and n extra messages.

THANK YOU!