21

Self Stabilization CS702 SEMINAR - Department of …theory/tcslab/combiopage/cbslide1… ·  · 2012-07-26Self Stabilization 1 ... ar Rah ul Dept. of CS & E, I IT Madras CS702 SEMINAR

  • Upload
    vudien

  • View
    214

  • Download
    1

Embed Size (px)

Citation preview

Self Stabilization 1

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

CS702 SEMINARSelf StabilizationCourse Instructor : Prof. C. Pandu RanganPresentation by : Hariharan Shankar Rahul (CS 93118)Self{stabilization is a very interesting concept propounded byDijkstra in the context of distributed systems as early as 1973.It has rami�cations in the context of fault{tolerance. We lookat some case{studies here to understand the design ofself{stabilizing algorithms.

Self Stabilization 2

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Overview� Notion of Self Stabilization� Importance of Self Stabilization� Some self-stabilizing algorithms{ Depth First Search{ Determining Centres and Medians of trees� Conclusion

Self Stabilization 3

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Self StabilizationThe notion of self stabilization was introduced by E.W. Dijkstrain 1973 in the context of distributed systems. However, theupsurge in self-stabilization research did not start until 88� 89.� A system is composed of two types of components: processesand interconnections between processes (such as shared mem-ory or message channels).� Local state is the state of a component of the system.� Global state of a system is the union of the local states ofits components.� Behaviour of a system consists of a set of states, a transitionrelation between them, and a set of fairness criteria on thetransition relation.

Self Stabilization 4

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

De�nition 1 A system S is self{stabilizing with respect toa predicate P , over its set of global states, if it satis�es thefollowing two properties:1. Closure: P is closed under the execution of S. That is,once P is established in S, it cannot be falsi�ed.2. Convergence: Starting from an arbitrary global state,S is guaranteed to reach a global state satisfying P within a�nite number of state transitions.States satisfying (not satisfying) P are legitimate/safe (illegiti-mate/unsafe) states respectively.De�nition 2 A system S is stabilizing with respect to pred-icates P and Q, over its set of global states (denoted Q! Pi.e. Q stabilizes to P ) if it satis�es the following properties:1. Closure: P is closed under the execution of S.2. Convergence: Starting from any global state satisfyingQ, S is guaranteed to reach a global state satisfying P withina �nite number of transitions.If S is self{stabilizing with respect to P , this may be restatedas TRUE ! P in S.

Self Stabilization 5

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Importance of self{stabilizationDe�nition 3 A transient failure is an event that may changethe state of a system but not its behaviour.� The property of self{stabilization models the ability of asystem to recover from transient failures under the assump-tion that they do not continue to occur. This implies thata self{stabilizing system need not be initialized.� Self{stabilization is a departure from previous approachesto fault tolerance which addressed the wide variety of faultsby countering the e�ects of their individual causes. How-ever, self{stabilization provides a uni�ed approach to fautltolerance by incorporating it in the design model.� While traditional methods such as replication or error cor-rection attempt to mask the occurrence of errors and thusprevent failure, self{stabilization guarantees recovery shoulda transient failure occur. Thus self{stabilization is a com-plementary approach to other methods of fault tolerance.

Self Stabilization 6

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Self{stabilizing AlgorithmsDepth{First SearchSystem Model:� A distributed system consists of n processors denotedby P1; P2; : : : ; Pn. Processor P1 is called special, whileall other processors are called regular. Regular processorshave no distinct identities.� Each processor can communicate with some other proces-sors, called its neighbours.� The system's communication graph is formed by repre-senting each processor as a node and connecting every pairof neighbours by an edge.� Communication between neighbours is carried out usingshared communication registers (called registers).Each register is serializable with respect to read and writeoperations.

Self Stabilization 7

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

� Any processor, Pi, writes in one register, ri, and may readfrom the register of any of its neighbours. Thus, each pairof neighbours Pi and Pj, are connected by an edge e =(Pi; Pj) that supports two{way communication.� Each processor Pi orders its edges by some arbitrary order-ing �i. For any edge e = (Pi; Pj) let �i(j) (�j(i)) be theedge{index of e according to �i (�j) respectively. We as-sume that for every processor Pi and any edge e = (Pi; Pj),Pi knows the value of �j(i).� We consider a processor and its register to be a single entity,thus the state of a processor fully describes the value storedin its register. Denote by Si the states of Pi.� A con�guration c 2 (S1 � S2 � : : :� Sn) of the systemis a vector of states, one for each processor.� Process activity is managed by a scheduler. At any givencon�guration, the scheduler activates a single processor whichexecutes a single atomic step i.e. an internal computationfollowed by a read or write, but not both.

Self Stabilization 8

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

De�nition 4 An execution of the system is a �nite sequenceof con�gurations E = (c1; c2; : : :), such that for i = 1; 2; : : :the con�guration ci+1 is reached from ci by a single atomicstep of some processor.De�nition 5 A fair execution is an in�nite execution inwhich every processor executes atomic steps in�nitely often.De�nition 6 An algorithm is self{stabilizing for a speci�ctask if any fair execution of the algorithm has a su�x that iswithin the set of legal executions of the task.The adjacent edges of every processor P can be categorized asfollows:1. Tree-edges : Incoming and Outgoing.2. Non tree-edges : Backward and Forward.The output of a distributed algorithm is called aDFS-markedgraph if it de�nes a DFS spanning tree and if every processorin the system can identify the category of each of its edges withrespect to the edges of the DFS spanning tree.

Self Stabilization 9

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

De�nition 7 The �rst DFS tree of a graph is the DFSspanning tree that is obtained by performing a (centralized)DFS algorithm, visiting the adjacent edges of every processorin the order induced by �i.For a given graph G with a special processor P1 (that plays therole of the root), each simple (loopless) path from P1 is denotedby ? followed by a sequence of the indices of the (outgoing)edges that de�ne the path.For example, (?; 5; 3) de�nes the path that begins with theroot, continues through the edge with index 5 in �1, reachesa processor Q through this edge and ends with a processor Rreached through the third edge of Q.A processor Q is associated with the set of simple paths fromthe root to Q. A lexicographic order � is de�ned over therepresentation of the above set of paths where ? is the minimalcharacter. For example, (?; 1) � (?; 1; 1) � (1; 2) � (1).De�nition 8 The smallest path in the set of simple paths ofPi is called the �rst path of Pi,and is denoted by fi.

Self Stabilization 10

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Note: The graph obtained by marking, for every 1 � i � n,the edge between Pi and Pi's father in fi is the �rst DFS tree.DFS Algorithmroot P11.do forever2. pathi :=?3.odnon-root Pi1.do forever2. for j := 1 to � do read pathj := read(pathj) od3. write pathi = minfjread pathj � �j(i),for 1 � j � �g4.odEvery processor Pi after reading the stabilized paths of its neigh-bours is able to identify the type of any of its incident edgesrelative to the �rst DFS tree. The edge e = (Pi; Pj) is:1. incoming i� pathi = pathj � �j(i).2. outgoing i� pathj = pathi � �i(j).3. backward i� pathj is a pre�x of pathi, e is not incoming.4. forward i� pathi is a pre�x of pathj , e is not outgoing.

Self Stabilization 11

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Theorem 1 Every fair execution has a su�x such that forevery con�guration in that su�x and for every processor Pi,pathi = fi.Thus the paths of all the processors eventually converge to the�rst path and hence, de�ne the DFS tree.� The memory requirement of the algorithm is O(n log�)where � is an upper bound on the degree of a node.� The time complexity is measured in rounds where eachround consists of an atomic step by each processor. Thealgorithms takes O(dn�) rounds where d is the diameter ofthe communicating graph.Note: This is a general scheme and can be used for other self{stabilizing algorithms e.g. BFS could be constructed using anorder relation on the length of the path.

Self Stabilization 12

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Finding the Centre and Median of a TreeWe assume that the underlying topology of processor inter-connection is a tree T = (V;E) where V = (1; 2; : : : ; n).l����xLegend: MedianCentre Notation: (e,w,h,s)l l l lll|��������(5,20,0,1) (4,15,1,2)(3,12,2,3)(3,11,2,4) (4,12,1,3)(5,17,0,1)(5,17,0,1)Fig.1: Parameters for a certain treeProposition 1 A tree has a single centre(median) or two ad-jacent centres(medians).The program of a process i can be expressed as:�[G[1] ! M [1]tG[2] ! M [2]]� Each guard G[j]; j = 1; 2 is a boolean function of the localvariable of process i and the local variables of its neighbours.

Self Stabilization 13

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

� Each move M [j]; j = 1; 2 is an atomic action that updatesthe local variable of process i.� �[S] corresponds to the repeated execution of the guardedstatement S until all guards are false.Denote by h and s two functions from the vertex set V to N .Notations:N(i) = fj : (i; j) 2 Eg denotes the set of neighbours of i.Nh(i) = fh(j) : (i; j) 2 Eg denotes the multi{set of h{valuesof neighbours of i.N�h (i) = Nh(i) � fmax(Nh(i))g denotes all of Nh(i) with onemaximum h{value removed.Ns(i) = fs(j) : (i; j) 2 Eg denotes the multi{set of s{valuesof neighbours of i.N�s (i) = Ns(i) � fmax(Ns(i))g denotes all of Ns(i) with onemaximum h{value removed.We impose the following conditions, called the height and sizeconditions respectively, on h and s.h(i) = 8>>>>><>>>>>: 0 if i is a leaf1 + max(N�h (i)) otherwise

Self Stabilization 14

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

s(i) = 8>>>>><>>>>>: 1 if i is a leaf1 + P(N�s (i)) otherwiseCentre{�nding algorithm for vertex i�[(i is a leaf )^ (h 6= 0) ! h 0t(i nonleaf )^ (h 6= 1 +max(N�h (i)) ! h 1 + max(N�h (i))]Median{�nding algorithm for vertex i�[(i is a leaf )^ (s(i) 6= 1) ! s(i) 1t(i nonleaf )^ (s(i) 6= 1 +X(N�s (i)) ! s(i) 1 +X(N�s (i))]Partial correctnessWe show that if the algorithm terminates, the nodes with thelargest h-values are the centres of T .De�nition 9 A function f : V ! N is an ordering func-tion if for all i 2 V , there exists at most one neighbour j ofi such that f (i) � f (j).Proposition 2 If all the h-values (s-values) satisfy the height(size) condition, then h (s) is an ordering function.

Self Stabilization 15

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Given an ordering function f : V ! N , de�ne a digraphG(f ) = (N(f ); A(f )) whose node set N(f ) = V and whosearc set A(f ) is de�ned asA(f ) = f(i; j)jj 2 N(i) and (f (j); j) is lexicographically the largestg.Lemma 1 The digraph G(f ) is connected and contains ex-actly one cycle. This cycle is of length two.Let i and j be the two nodes in G(f ) that belong to the uniquecycle. Assume that f (i) � f (j). On deleting the arcs (i; j)and (j; i), we obtain two directed trees. Denote the directedtree rooted at i as Ti(f ) = (Ni(f ); Ai(f )).Proposition 3 Each arc in Ti(f ) and Tj(f ) is directed froma node to its parent and if k is a non{leaf node in Ti(f ) or inTj(f ), then f (k) > f (l) for each child l of k.Thus, if f (i) > f (j), then i has the largest f{value in T .Otherwise, i and j have the largest f{values in T .Theorem 2 Let the h{values of all vertices in T satisfy theheight condition. Then centre(T ) = fkjh(k) � h(l)8l 2 V g.

Self Stabilization 16

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Theorem 3 Let the s{values of all vertices in T satisfy thesize condition. Then median(T ) = fkjs(k) � s(l)8l 2 V g.Note: If all h-values (s-values) satisfy the height (size) condi-tion, then each process can determine if it is a centre (median)of T , by just looking at the h-values (s-values) of its neighbours.TerminationWe show that the centre{�nding algorithm terminates after a�nite number of moves.We call a move by process i a decreasing move if it decreases theh{value of i, otherwise we call the move an increasing move.Denote by M(i; p) a move by process i that is the pth move inan arbitrary execution sequence of the centre{�nding algorithm.M(i; p; #) denotes that the move M(i; p) is decreasing.Consider a non{initial decreasing move M(i; p; #) made by i.Let M(i; p0) (not necessarily decreasing) where p0 < p be themove made by process i just before M(i; p).We note thath(i; p0) = max(N�h (i; p0)) + 1 (1)h(i; p� 1) > max(N�h (i; p� 1)) + 1 (2)

Self Stabilization 17

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

max(N�h (i; p� 1)) < max(N�h (i; p0)) (3)9j 2 N(i); h(j; p � 1) � max(N�h (i; p� 1)) (4)j makes at least one decreasing move between M(i; p0) andM(i; p). Let M(j; q; #) be the last decreasing move by processj such that p0 < q < p. Then de�ne cause(M(i; p)) =M(j; q).If M(i; p) is initial, de�ne cause(M(i; p)) = M(i; p).Lemma 2 If M(i; p0) and M(i; p) are decreasing moves byprocess i, then cause(M(i; p0)) 6= cause(M(i; p)).Lemma 3 Let M(i; p) be a decreasing move by process i. IfM(i; p) is not the initial move by process i, then the movecause(cause(M(i; p))) is not made by process i.De�nition 10source(M(i; p)) = 8>>>>>>>>>>>>>>>><>>>>>>>>>>>>>>>>: M(i; p) M(i; p) decreasing,initial movesource(cause(M(i; p))) M(i; p) decreasing,non{initial move

Self Stabilization 18

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Lemma 4 LetM(i; p) be a decreasing move made by process iwith source(M(i; p)) = M(m; l). LetM(i0; p0); M(i1; p1); : : : ;M(ia; pa) be a sequence of moves such that1. M(i0; p0) = M(i; p) and M(ia; pa) = M(m; l).2. M(ib+1; pb+1) = cause(M(ib; pb)).3. M(ib; pb) 6= M(ib+1; pb+1), for all b; 0 � b � a� 1.Then the sequence i0; i1; : : : ; ia is a path in T .Lemma 5 LetM(i; p0) andM(i; p) be distinct decreasing movesmade by process i. Then source(M(i; p0)) 6= source(M(i; p)).Lemma 6 Decreasing Moves Lemma: Each process in T canmake at most n decreasing moves and the processes in T canmake a total of at most n2 decreasing moves.Let the length of the smallest pre�x of the execution sequencecontaining all the decreasing moves be l. Then E = M( ; l +1);M( ; l + 2); : : : contains only increasing moves.Lemma 7 E is �nite and hence, the total number of increas-ing moves made by the algorithm is �nite.

Self Stabilization 19

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Time ComplexityDe�ne the state of the centre-�nding algorithm to be the n{dimensional vector of natural numbers (h(1); h(2); h(3); : : : ; h(n)).Let h(i; q) denotes the h-value of process i in an arbitrary stateq. Given two states q0 and q, we say that q0 ! q if there is amove that takes the algorithm from state q0 to q.Let q = (h(1); h(2); : : : ; h(n)) and q0 = (h0(1); h0(2); : : : ; h0(n))be two n{dimensional vectors. Then q0 dominates q if hi � h0ifor all i, 1 � i � n.Lemma 8 Suppose that q0 and q0o are states of the centre{�nding algorithm such that q0 is dominated by q00. Let q bea state such that q0 �! q. Then there exists a state q0, withq00 �! q0, that dominates q.Let hM (q0) be the maximum h{value that any process canachieve when the algorithm is executed starting from state q0.Corollary 1 Let q0 and q00 be states of the centre{�nding al-gorithm such that q0 is dominated by q00. Then hM (q0) �hM (q00).

Self Stabilization 20

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Lemma 9 Suppose that q0 = (ch; ch; : : : ; ch) for some ch 2 Nand q00 = (0; 0; : : : ; 0). Then hM (q0) � hM (q00) + ch.Let hm(q0) denote the maximum h{value of any process in stateq0.Lemma 10 Let q0 be a state of T . Then, hM (q0) � hm(q0)+bn=2c.Theorem 4 The centre{�nding algorithm can make at mostO(n3 + n2hm(q0)) moves starting from q0.Similarly, the following theorem regarding the time{complexityof the median algorithm may be proved.Theorem 5 The median{�nding algorithm can make at mostO(n3sm(q0)) moves starting from q0.

Self Stabilization 21

Hariharan Shankar Rahul Dept. of CS & E, IIT Madras

Conclusion� We have seen the motivation and meaning of self{stabilizingalgorithms.� We have also seen case{studies of two interesting and usefulproblems in graph theory.� However, it is not easy to develop self{stabilizing algorithmsbecause of problems of asymmetry and termination.� In order to counter these, several notions such as stabiliza-tion, probabilistic self{stabilization and pseudo{stabilization.� There are several interesting open self{stabilization prob-lems such as determining centroids, cores, path{centres,st-numbers of trees as well as arbitrary graphs.