Upload
apoorva-ranjan
View
218
Download
0
Embed Size (px)
Citation preview
8/14/2019 5_DSS_Global State.ppt
1/26
Global State Collection
8/14/2019 5_DSS_Global State.ppt
2/26
Introduction
In a distributed system, each process executes actions on thebasis of local information that consists of its own state, and thestates of its neighbors, or messages through the incomingchannels.
Many applications need to find out the global state of thesystem by collecting the local states of the componentprocesses like :
Computation of the network topology
Counting the number of processes in a distributed system Detecting termination Detecting deadlock Detecting loss of coordination
8/14/2019 5_DSS_Global State.ppt
3/26
Global State collection
The algorithms for global state collection have beenclassified into various types:
Probe-echo algorithm,
Wave algorithm,
Heartbeat algorithm
8/14/2019 5_DSS_Global State.ppt
4/26
Wave Algorithms
A wave algorithm is a distributed algorithm that satisfies thefollowing three requirements:
Termination:Each computation is finite
Decision:Each computation contains at least one decide
event
Dependence: In each computation each decide event iscausally preceded by an event in each process
8/14/2019 5_DSS_Global State.ppt
5/26
Traversal Algorithms
A traversal algorithm is an algorithm with thefollowing three properties:
In each computation there is one initiator, which
starts the algorithm by sending out exactly onemessage.
A process, upon receipt of a message, either sends
out one message or decides.
The algorithm terminates in the initiator and when thishappens, each process has sent a message at leastonce.
8/14/2019 5_DSS_Global State.ppt
6/26
Waveform Algorithm
One or more initiators start a computation.
The computation in a non-initiator node is triggeredby the computation in an adjacent node.
Each node reaches local termination when a
predefined local goal is reached.
The system-wide computation terminates in abounded number of steps after it has been initiated.
8/14/2019 5_DSS_Global State.ppt
7/26
AN ELEMENTARY ALGORITHMFOR BROADCASTING
Each process i has a stable value s(i) associated withit.
The goal is to devise an algorithm by which everyprocess i can broadcast its value s(i) to every otherprocess in this system.
At the end, each process i will have a setV.i = {forall k : 0 k N 1 : s(k)}.
InitiallyV.i = {s(i)}.
8/14/2019 5_DSS_Global State.ppt
8/26
Continued..
Every process i will periodically (i) send itscurrentV.i along each of its outgoing channels
Receive values along the incoming channels to
updateV.i.
The operation resembles the pumping of bloodin the heart, so
Heartbeat algorithms!
8/14/2019 5_DSS_Global State.ppt
9/26
Two important issues need attention:
The termination of the algorithmThe message complexity
To save unnecessary work, it makes little sense to sendV.i, if it has not changed since the last operation.
Furthermore, even ifV.i has changed since the last
send operation, it suffices to send the incrementalchange onlythis will keep the message size small.
8/14/2019 5_DSS_Global State.ppt
10/26
program broadcast (for process i}
defineV.i, W.i: set of values;
initiallyV.i = {s(i)}, W.i = {and every channel isempty}
1. doV.i W.isend (V.i \ W.i) to every outgoingchannel;
W.i := V.i
2. empty (k, i) receive X from channel (k, i);V.i := V.i U X
8/14/2019 5_DSS_Global State.ppt
11/26
empty(i.k) => W.i V.k.
Induction step. Between two consecutive executions ofstatement 1, statement 2 must be executed at least once.
Assume W.i V.k holds after process i executes the firststatement r times, and (i, k) is empty.
We will show that W.i V.k holds after process i executes thefirst statement (r + 1) times, and (i, k) is empty.
8/14/2019 5_DSS_Global State.ppt
12/26
8/14/2019 5_DSS_Global State.ppt
13/26
Algorithm broadcast terminates when everyprocess has received the value of s(j) from
every process j = i.
Proof.When all guards are false, the conditionV.i =W.i holds for each i, and the channels are empty.
From Lemma 9.1, empty (i. k)=>W.i V.k.Therefore,V.i V.k.
Now consider a directed cycle, If for every pair ofprocesses i and k across a channel (i, k) the conditionV.i V.k holds, then for i,j :V.i = V.j.
8/14/2019 5_DSS_Global State.ppt
14/26
Continued..
In a strongly connected graph every pair of processes(i,j) are contained in a directed cycle, therefore theconditionV.i = V.j must hold for every pair ofprocesses in the system.
Also, since s(i)V.i, and no element is removed froma set, eachV must contain all the s-values.
8/14/2019 5_DSS_Global State.ppt
15/26
Message Complexity
A process i broadcasts only whenV.i changes. Starting from the initial value s(i),V.i can
change at most (N 1) times.
Also, since each node can have at most (N 1) neighbors, each broadcast may consist of atmost N 1 messages.
Thus a typical process can send at most (N 1)2messages.
8/14/2019 5_DSS_Global State.ppt
16/26
TERMINATION DETECTION ALGORITHM
One possible mechanism of distributing thecomputation to the various processes is as follows:
The task is initially assigned to an initiator node.
The initiator delegates various parts of this task to itsneighbors, which delegate parts of their work to theirneighbors, and so on.
As the computation makes progress, these nodesexchange messages among themselves.
8/14/2019 5_DSS_Global State.ppt
17/26
States of a node
Active and Passive
A process is active, when it has some enabled guards.
If a process is in a passive state, then it does notnecessarily mean that the process will always remainpassivea message sent by an active neighbor maywake up the process.
An active process on the other hand eventuallyswitches to a passive state, when it has executed allits local actions.
8/14/2019 5_DSS_Global State.ppt
18/26
Active & Passive Processes
8/14/2019 5_DSS_Global State.ppt
19/26
Termination of a process
Termination corresponds to the following three criteria:
(a) every process is in a passive state
(b) all channels are empty
(c) the global state of the system satisfies the desiredpostcondition.
To see why termination detection is important, remember that
many computations in distributed systems runs in phases. Eachphase of a computation runs over the entire system, and tolaunch phase (i+1), the initiator has to ascertain that phase ihas terminated.
8/14/2019 5_DSS_Global State.ppt
20/26
THE DIJKSTRASCHOLTEN ALGORITHM
The computation initiated by a single initiator and spreading
over to several other nodes in the network is called a diffusingComputation.
Termination is reported to the initiator as a single event.
There are two kinds of messages in the network:1. signals propagate along the direction of the Edges.
2. Acknowledgments propagate in the opposite direction.
The initiator is a special node (called the environment node)that has no edge directed toward it.
Every other node is called an internal node, and is reachable
from the environment node via the edges of the directed path.
8/14/2019 5_DSS_Global State.ppt
21/26
Global State Collection
8/14/2019 5_DSS_Global State.ppt
22/26
INV2. (C > 0) (D = 0)
8/14/2019 5_DSS_Global State.ppt
23/26
TERMINATION DETECTION ON A
UNIDIRECTIONAL RING
The algorithm works on a unidirectional ring that is embeddedon the topology of the given networkthe order of theprocesses in the ring is used to decide the order in which thetoken traverses the network.
The ring topology has no connection with the sending andreceiving of messages by the underlying algorithmso amessage can be sent by one process to another as long as apath exists, even if they are not neighbors in the ring.
All communication channels are assumed to be FIFO.
8/14/2019 5_DSS_Global State.ppt
24/26
Active & Passive Processes
Assume that process 0 is the initiator of termination detection .
The initiator initiates the algorithm by sending out a tokenittraverses the network and eventually returns to the initiator.
A process k accepting the token will not forward it to
k1 until it becomes passive.
When the initiator receives the token back, it detects termination.
8/14/2019 5_DSS_Global State.ppt
25/26
Limitations
What if the token is with process k, but a processm(n 1 > m > k) that was passive, now becomesactive by receiving a message from some process l(k> l > 0)?
This could lead to a false detection, since theactivation of process m will go unnoticed!
To prevent this, refine the scheme by assigning the
colors white and black to processes and the token.
8/14/2019 5_DSS_Global State.ppt
26/26
Rules: ForUNIDIRECTIONAL RING
Initially, all processes are white, and the initiatorsends a white token to process (n 1).
Rule 1. When a non-initiator process sends amessage to a higher numbered process, it turns black.
Rule 2. When a black process sends a token, thetoken turns black. If a white process forwardsa token, then it retains the color of the token.
Rule 3.When a black process sends a token to itssuccessor, it turns white.