Depth-First Token Circulation Algorithms. FRANCK PETIT. LaRIA, Université de Picardie Jules Verne, France. VINCENT VILLAIN. LaRIA, Université de Picardie ...
Time and Space Optimality of Distributed Depth-First Token Circulation Algorithms F RANCK P ETIT LaRIA, Universit´e de Picardie Jules Verne, France V INCENT V ILLAIN LaRIA, Universit´e de Picardie Jules Verne, France
1 Introduction The depth-first token circulation problem is to implement a token circulation scheme where the token is passed from one processor to another in the depthfirst order such that every processor gets the token at least once in every token circulation cycle. The depth-first token circulation scheme has many applications in the distributed systems. The solution to this problem can be used to solve the mutual exclusion, spanning tree construction, synchronization, and many other important tasks. Four key performance issues of distributed algorithms are (i) the time complexity, (ii) the memory requirement, (iii) the number of messages exchanged, and (iv) the message size. In our work, we computed the number of states required per processor instead of the number of bits/words required because the former is a more accurate metric. The property of self-stabilization in distributed systems was first proposed by Dijkstra [2]. A self-stabilizing system, regardless of the initial states of the processors and initial messages in the links, is guaranteed to converge to the intended behavior in finite time. In the same paper, Dijkstra introduced the state model in which the message communication is simulated by the ability of processors to read their own state and that of their neighbors. In this paper, we first propose two optimal depth-first token circulation algorithms for tree structured networks using the state model [2]. One runs on trees having a (minimal) sense of direction. The other runs for trees without any sense of direction. Both algorithms are both space (or state) and time optimal. The first surprising result is that the optimal number of states per processor (for both algorithms) is about the half of what it was previously expected in [16]. The second surprising result is that the stabilization time of both algorithms is 0 steps, i.e., the This
work has been supported in part by the Pole of Modelization of Picardie.
1
2
Distributed Data and Structures 2
system always maintains the desirable behavior. Such distributed algorithms are called snap-stabilizing algorithms (introduced in [1]). Next, we investigate optimalities in depth-first token circulations in general rooted networks. We present several algorithms in the state model which are the most efficient known self-stabilizing depth-first token circulation algorithms for general networks. Some of them are asymptotically optimal in terms of the number of states per processor. We also present the first depth-first token circulation algorithm for general networks in the message-passing model. This algorithm uses messages of size O(1) bits (5 bits). The number of messages of the proposed algorithm (after stabilization) is very close to the optimal number of messages for the depth-first token circulation.
2 Preliminaries In this section, we define the distributed systems and programs considered in this paper, and state what it means for a protocol to be snap-stabilizing. System. A distributed system is an undirected connected graph, S = (V; E ), where V is a set of nodes (jV j = n) and E is the set of edges. Nodes represent processors and edges represent bidirectional communication links. A communication link ( p; q) exists iff p and q are neighbors. We consider networks which are asynchronous. No processor, except the one, called the root and denoted by r, has any identity. Every processor p (including r) can distinguish all its links. To simplify the presentation, we refer to a link ( p; q) of processor p simply by the label q. We assume that the labels, stored in the set Np , are arranged in some arbitrary order p . The number of neighbors of p, jNp j, is called the degree of p and is denoted by ∆ p . Programs. The program consists of a set of shared variables (henceforth referred to as variables) and a finite set of actions. A processor can only write to its own variables and can only read its own variables and variables owned by the neighboring processors. A definition of semi-uniform algorithms is given in [3]: Every processor, except one (the root), having the same degree executes the same program. In this paper, we consider weak semi-uniform algorithms in the following sense: Every processor, except the root, executes the same program. Each action is of the following form: < label >:: < guard > ! < statement >. The guard of an action in the program of p is a boolean expression involving the variables of p and its neighbors. The statement of an action of p updates one or more variables of p. An action can be executed only if its guard evaluates to true. We assume that the actions are atomically executed, meaning the evaluation of a guard and the execution of the corresponding statement of an action, if executed,
Time and Space Optimality of Depth-First Token Circulation
3
are done in one atomic step. The atomic execution of an action of p is called a step of p. The state of a processor is defined by the values of its variables. The state of a system is a product of the states of all processors ( 2 V ). In the sequel, we refer to the state of a processor and system as a (local) state and configuration, respectively. Let a distributed protocol P be a collection of binary transition relations denoted by 7!, on C , the set of all possible configurations of the system. A computation of a protocol P is a maximal sequence of configurations e = (γ0 ; γ1 ; :::; γi ; γi+1 ; :::), such that for i 0; γi 7! γi+1 (a single computation step) if γi+1 exists, or γi is a terminal configuration. Maximality means that the sequence is either infinite or finite and no action of P is enabled in the final configuration. All computations considered in this paper are assumed to be maximal. The set of computations of a protocol P in system S starting with a particular configuration α 2 C is denoted by Eα . The set of all possible computations of P in system S is denoted as E . We assume a distributed daemon, i.e., during a computation step, one or more processors execute a step and a processor may take at most one step. A processor p is said to be enabled at γ (γ 2 C ) if there exists an action A such that the guard of A is true in γ. We also assume the daemon to be weakly fair, meaning that if a processor p is continuously enabled, then p will be eventually chosen by the daemon to execute an action. Snap-Stabilization. Let X be a set. x ` P means that an element x 2 X satisfies the predicate P defined on the set X . Definition 1 (Snap-stabilization) The protocol P is snap-stabilizing for the specification SPP on E if and only if the following condition holds: 8α 2 C : 8e 2 Eα :: e ` SPP .
3 Time and State Optimality In Tree Networks In [2], Dijkstra defined a token as “the ability of a processor to make a move,” i.e., to change its (local) state. In [8, 17], the authors relaxed Dijkstra’s original token definition and defined a token as “the ability for a processor to make some particular moves”. This new notion of token allows processors to move concurrently while preserving the mutual exclusion property, i.e., at most one privileged move (which corresponds to “holding the token”) is enabled at any time. We use this new token definition introduced in [8, 17]. Villain [18] used the power of this new definition to introduce a new very useful tool called the cleaner. The cleaner was first used to design a self-stabilizing depth-first token circulation algorithm for tree networks in [11]. The state optimality of [11] was proven in [15]. We use this tool (cleaner) to design the depth-first token circulation algorithms on trees which are both states and time optimal.
4
Distributed Data and Structures 2
We also study the effect of “having” or not having a (minimal) sense of direction [7] of such tree networks. An interesting question is “Does a depth-first token circulation on trees having no sense of direction make sense?”. To answer this question, we must consider different applications of the token circulation scheme. The token circulation protocols can be used to compute a global task, to maintain a global structure, or a global property of a system (e.g., the mutual exclusion among the processors). Any processor can initiate a global computation using a token circulation. So, any processor can be the root of a token circulation. To deal with the concurrent executions of the same global task, the identity of the associated network component (e.g., the resource or the root identity) must be added to the messages exchanged in the network, and also, must be maintained by every processor. This requirement is necessary for both self-stabilizing and non-stabilizing algorithms. So, each processor in the network has to maintain n spanning trees rooted at n distinct processors of the network (n being the number of processors in the network). Thus, for every spanning tree, every processor needs to maintain a subset of its neighbors as descendants, and a parent pointer. So, the total memory requirement of each processor p is O((2∆ p )n ) states (or O(∆ p n) bits), where ∆ p is the degree of the processor p. On the other hand, to design a depth-first token circulation for the above situation, i.e., to deal with the multiple initiators, if we use a rooted tree without any sense of direction, every processor needs to maintain only one spanning tree of the network (instead of n spanning trees). So, every processor p needs a space of 2∆ p states or ∆ p bits in order to maintain the spanning tree. The same amount of space would also be required in a non-stabilizing depth-first token algorithm for the tree networks without any sense of direction. Tree Structured Networks. We denote the set of leaf processors by L and the set of internal processors by I. We denote the set of processors in the tree, rooted at processor p, as Tp (hereafter, called the tree Tp ). Note that V = frg[ I [ L = Tr . In the remainder, h will denote the height of the tree rooted at r, Tr . Every processor p which is not the root (p 6= r) has a unique parent, denoted by Pp , such that Pp is the neighbor of p (Pp 2 Np ) on the path from p to r, or Pp = r. We denote the set of descendants of any processor p 2 I [frg by D p , i.e., D p = Np if p = r, D p = Np nfPpg if p 2 I, and D p = 0/ if p 2 L.
3.1 Specification of the Depth-First Token Circulation Let us quickly review the well-known depth-first search scheme (henceforth referred to as DFTC scheme). The DTFC scheme is the repetition of a DFTC cycle. Informally, a DFTC cycle is defined by the following actions: The DFTC cycle is initiated by the root r. The token then traverses all processors in the depth-first order. A DFTC cycle ends when the root holds the token after every processor has been visited by the token at least once.
Time and Space Optimality of Depth-First Token Circulation
5
Based on the above description, we define the DFTC cycle in terms of actions: Forward action, Backward action, and Termination action. We will use the term DFTC-action to refer to one of the above three actions. Definition 2 (DFTC-action ) A DFTC-action is one the three following action which occurs on Processor p:
[F-action ] Processor p sends a token to one of its descendants (2 D p ) (Forward). [B-action ] Processor p sends a token to its parent Pp (Backward). [T -action ] The root r executes a special internal action to terminate the current DFTC cycle (Termination). Specification 1 (DFTC Cycle) A finite computation e 2 E is called a DFTC Cycle, denoted by e ` DFTC-cycle, if and only if the following conditions are true: [L1] At least one processor p, called an initiator, executes a DFTC-action . [L2] If an internal processor p (p 2 I) receives a token from its parent Pp , then p eventually executes a F-action for all its descendants (2 D p ). [L3] If a leaf processor p (p 2 L) receives a token from its parent Pp , then p eventually executes a B-action . [L4] If an internal processor p (p 2 I) receives a token from one of its descendant (2 D p ), then p eventually executes a B-action . [L5] If the root r receives a token from one of its descendants (2 Dr ), then r eventually executes a T -action . [S1] If a processor p sends a token twice, then p receives a token between both sendings. [S2] A T -action cannot occur more than once. Conditions [L1] to [L5] are called the liveness properties, and Conditions [S1] and [S2] are called the safety properties. From Condition [L1], there exists at least one initiator in a DFTC cycle. Let Init be the set of processors that initiate the DFTC cycle. Definition 3 (Normal DFTC Cycle) We call a DFTC cycle as a normal DFTC cycle if Init = frg. From Specification 1, it is easy to show that starting from any configuration of a normal DFTC cycle, the system contains only one initiator p executing a DFTC-action . Every F-action extends the DFTC cycle until the token reaches a leaf processor q executing its B-action . Similarly, every B-action extends the DFTC cycle (i.e., succession of actions F-action and B-action ) until the root terminates the DFTC cycle (T -action ). Thus, any suffix of a DFTC cycle is also a DFTC cycle. We state this property formally in the following property: Property 1
8e ` DFTC-cycle 8e ;
0
;
e00 : e = e0 e00 :: e00 ` DFTC-cycle.
6
Distributed Data and Structures 2
Specification 2 (DFTC Scheme) We define a computation e starting from a configuration α (e 2 Eα ) as a DFTC scheme, denoted by e ` SP DFTC , if e is an infinite sequence of DFTC cycles e0 ; e1 ; : : : (8i 0 : ei ` DFTC-cycle) such that 8i 1, ei is a normal DFTC cycle.
3.2 Depth-First Token Circulation in Trees having a Minimal Sense of Direction In this subsection, we consider rooted tree networks having a minimal sense of direction (in the following simply referred to as a sense of direction): Every processor p (p 6= r) knows the one of its links leads to its predecessor Pp . Minimum Number of States. We consider the minimum number of states required per processor to implement a DFTC scheme on a tree having a sense of direction. Theorem 1 ([15]) Let s p be the set of states of processor p. For every p 2 V , js p j ∆ p + 1 to implement a DFTC cycle on a tree network having a minimal sense of direction. Snap-Stabilizing Depth-First Token Circulation Algorithm. Algorithm 1 describes the depth-first token circulation scheme. Every processor p maintains a state variable S p . If p = r, then S p 2 Np [ fidleg. If p 2 I, then S p 2 D p [ fidle; doneg. Otherwise (p 2 L), S p 2 fidle; doneg. We assume that for every p 2 frg[ I, 8q 2 Np : q p idle. Note that S p can never be equal to Pp . Algorithm 1 repeats DFTC cycles forever. A processor holds the token if Forward ( p) or Backward ( p) is true. A processor p is said to be idle (S p = idle) when p is ready to participate in the next DFTC cycle. Similarly, a processor p (p 6= r) is in state done (S p = done) when p has completed the current DFTC cycle, i.e., the token circulation in Tp is complete. Processor p 6= r receives a token for the first time (i.e., Forward ( p) becomes true) in a DFTC cycle only when it is idle and its parent Pp selected p as its successor in the current DFTC cycle. After p receives the token for the first time during a DFTC cycle (i.e., Forward ( p) is true), p waits until the next descendant q of p (see Function Next p , q 2 D p ) is idle (see Macro Permission( p)). Then p selects q and passes the token to q by setting S p to q (see Action O1). Eventually, the token will visit all processors in Tq . So, Processor q will be done, and the token will backtrack to p (i.e., Pq ). Now, p executes Action O1 to select another successor, if any. This allows q to execute Action O2 to change its state to idle, concurrently to the DFTC cycle. Similarly, when the root r receives the token from its current successor, r executes Action R1 to select another successor or to initiate the next DFTC cycle.
Time and Space Optimality of Depth-First Token Circulation
7
Algorithm 1 (T C SoD ) Depth-First Token Circulation In Trees With Sense Of Direction Algorithm for the root r: variable: S p 2 Np [fidleg Function Next p (q = min p fq0 2 Np :: q0 p S p g) if q exists, idle otherwise; Predicates (S p = idle) Forward ( p) Backward ( p) (9q 2 Np :: S p = q ^ Sq = done) Permission( p) (Next p = idle _ SNextp = idle) Action R1 :: (Forward ( p) _ Backward ( p)) ^ Permission( p) ! S p := Next p ; Algorithm for the other nodes (p 6= r): variable: S p 2 D p [fidle; doneg Function Next p (q = min p fq0 2 D p :: q0 p S p g) if q exists, done otherwise; Predicates Forward ( p) (SPp = p) ^ (S p = idle) Backward ( p) (SPp = p) ^ (9q 2 D p :: S p = q ^ Sq = done) Permission( p) (Next p = done _ SNextp = idle) Clean( p) (S p = done) ^ (SPp 6= p) FalseRoot ( p) (SPp 6= p) ^ (S p 2 D p ) Actions O1 :: (Forward ( p) _ Backward ( p)) ^ Permission( p) ! S p := Next p ; O2 :: Clean( p) ! S p := idle; ! S p := idle; OC :: FalseRoot ( p)
Note that due to asynchrony in the network, some processors may be involved in a DFTC cycle whereas some other are still done of the previous cycle. But, we need to make sure that these two cycles do not confuse each other. We solve this problem by adding two preventives in the algorithm. (i) A processor p is allowed to change its state from done to idle (Action O2) only once its parent Pp stopped to select p. (ii) A processor p can select its next successor q (q 2 D p ) once Sq = idle (i.e., q executed Action O2). Thus, the processors which are slow to execute their Action O2, are protected from the next DFTC cycle. Since the systems we consider require no initialization, they can start from any configuration. Informally, a configuration is an “abnormal” configuration if there exists at least an internal processor p (p 2 I) and there exists q 2 D p such that S p = q, and SPp 6= p. We call such a processor a false root. In such a configuration, Predicate FalseRoot ( p) is true, and p eventually executes Action OC. By induction, every false root eventually disappears in the worst case once it reaches a leaf processor by successive execution of Action OC. It is easy to see that the removal of the false roots does not interfere with the normal DFTC cycle. That
8
Distributed Data and Structures 2
allows us to claim that Algorithm T C SoD is snap-stabilizing. Furthermore, the following result follows from Algorithm T C SoD and Theorem 1: Theorem 2 Algorithm T C SoD is optimal in terms of the number of states per processor to implement the DFTC cycle on a tree network having a minimal sense of direction. Algorithm T C SoD is Snap-Stabilizing. We use the notation ( p; γ) ` FalseRoot to indicate that processor p (p 2 I) is a false root in configuration γ, i.e., (SPp 6= p) ^ (S p 2 D p ). Similarly, ( p; γ) 6` FalseRoot denotes that p is not a false root in configuration γ. FRγ denotes the number of false roots in configuration γ. The following lemma shows that a processor can become a false root only when a neighboring false root is pushed down towards one of its descendants. Lemma 1 8 p 2 I : 8α; β 2 C : α 7! β :: ( p; α) 6` FalseRoot ^ ( p; β) ` FalseRoot ) (Pp 2 I ) ^ (SPp = p in α) ^ ((Pp ; α) ` FalseRoot ) ^ ((Pp; β) 6` FalseRoot ). Proof. Since, ( p; α) 6` FalseRoot, we have to consider three possible situations in α: (1) S p = idle, (2) (9q 2 D p :: S p = q) ^ (SPp = p), and (3) S p = done in α. If S p = done, then no action can change S p such that S p = q (q 2 D p ) will be true in β. Thus, this case does not satisfy the assumptions made in the lemma statement. So, we consider the two first cases only. Assume first that S p = idle in α. Since ( p; β) ` FalseRoot, p executes an action in α such that S p changes from idle in α to q (q 2 D p ) in β. The only possible action that can make this happen is Action O1. This implies that SPp = p in α, and Pp executes an action in α such that SPp 6= p in β. The only possible action which Pp can execute to make this change is Action OC. Hence, Pp 2 I and (Pp ; α) ` FalseRoot. After Pp executes OC in α, SPp = idle becomes true in β. So, (Pp ; β) 6` FalseRoot. Secondly, assume that (9q 2 D p :: S p = q) ^ (SPp = p) in α. Then, Pp cannot execute either Action O1 or Action R1 in α. So, the only possible action Pp can execute in α is Action OC. Hence, as in Case 1, Pp 2 I and (Pp ; α) ` FalseRoot and (Pp ; β) 6` FalseRoot. 2 Lemma 1 means that Algorithm T C SoD cannot create any false root, and that if there exists some false roots, then, each of them is pushed toward the leaf processors, whatever the state of its descendants. From Algorithm 1, it is obvious that a false root can change its state only by executing Action OC. So, by successive executions of Action OC, every false root eventually reach a leaf processor and then, disappears. Since the system is a tree of height h: Theorem 3 All false roots disappear in O(h) steps.
Time and Space Optimality of Depth-First Token Circulation
9
Theorem 4 (snap-stabilizing) Algorithm T C SoD is a snap-stabilizing DFTC scheme. Proof Outline. Let p be the processor holding the token of the normal DFTC cycle. From Algorithm T C SoD , it is obvious that p can be prevented from executing its Action R1 or Action O1 only if SNext p 6= idle (p 2 frg[ L). If SNext p = done, then Clean(Next p ) is true and Next p eventually executes Action O2. If SNext p 6= done, then p 2 I and p is a false root. By Theorem 3, every false root eventually disappears, and then, Next p is eventually idle. So, by induction, the token of the normal DFTC cycle is eventually passed among the processors in the depth-first order. Thus, Algorithm TCSoD is a snap-stabilizing 2 DFTC scheme. Now, let us consider the worst delay of the first DFTC cycle of Algorithm
T C SoD . Consider that p is a false root, i.e., SPp 6= p and S p 2 D p . Also, assume
that Forward (Pp) or Backward (Pp ) is true, and p = NextPp . So, Pp is not enabled because NextPp (p) is not in state idle. Hence, Pp cannot execute any action while p does not change its state. The only way p can change its state in the current configuration is by executing OC. Also, the guard of OC does not depend on the status of the current successor of p. So, the time to allow Pp to execute either Action R1 or Action O1 (Pp = r or not) depends only on the execution of OC by p. It is easy to observe that the concurrent executions of OC by processors in different branches of the tree do not affect each other. Thus, we can assume that all the processors enabled to execute OC, execute OC during the same computation step. Once p executes OC, S p becomes enabled idle and S p may be enabled to execute its action. So, we can claim the following result: Theorem 5 The delay to start the first DFTC cycle using Algorithm T C SoD is bounded by 1 step.
3.3 Depth-First Token Circulation in Trees having No Sense of Direction In this subsection, we consider rooted tree networks having no sense of direction, i.e., no processor p (p 6= r) knows the one of its links leads to its predecessor Pp . Minimum Number of States. We consider the minimum number of states required per processor to implement a DFTC scheme on a tree having no sense of direction. Theorem 6 ([15]) Let s p be the set of states of processor p. For every p 6= r, js p j ∆ p + 2, and for p = r, js pj ∆ p + 1, to implement the weak semi-uniform DFTC cycle on a tree network having no sense of direction.
10
Distributed Data and Structures 2
Note that this result holds for weak semi-uniform distributed algorithm, i.e., every processor, except the root, executes the same program. Considering semiuniform algorithms [3], i.e., every processor with the same degree executes the same program (except the root), Theorem 6 holds for processors p such that ∆ p 3. That means that for processors p (p 6= r) with ∆ p 2, only ∆ p + 1 states are sufficient. So, we can design a not snap-stabilizing but self-stabilizing algorithm such that every processor p 6= r having ∆ p 2 needs ∆ p + 1 states only. Snap-Stabilizing Depth-First Token Circulation Algorithm. Algorithm 2 describes the depth-first token circulation scheme in trees having no sense of direction. As the algorithm for the root r is exactly the same as in Algorithm T C SoD , we present the algorithm for other processor only. Algorithm 2 (T C nSoD ) Depth-First Token Circulation In Trees Without Sense Of Direction Algorithm for the root r: (See Algorithm 1)
Algorithm for the other nodes (p 6= r): variable: S p 2 Np [fidle; doneg Macro Pred p fq 2 Np :: Sq = pg Function Next p (q = min p fq0 2 Np n (Pred p [frg) :: q0 p S p g) if q exists, done otherwise; Predicates Forward ( p) (jPredp j = 1) ^ (S p = idle) Backward ( p) (jPred p j = 1) ^ (9q 2 Np :: S p = q ^ Sq = done) Permission( p (Next p = done _ SNextp = idle) Clean( p) (jPredp j = 0) ^ (S p = done) FalseRoot ( p) (jPred p j = 0) ^ (S p 2 Np ) FreeCycle( p) (jPred p j = 1) ^ (S p 2 Pred p ) Actions O1 :: (Forward ( p) _ Backward ( p)) ^ Permission( p) ! S p := Next p ; O2 :: Clean( p) ! S p := idle; OC :: FalseRoot ( p) _ FreeCycle( p) ! S p := idle;
The normal DFTC cycle behaves as in Algorithm T C SoD . Every processor p maintains the same state variable S p , except that for every processor p 6= r, S p 2 Np [ fidle; doneg. That is, every processor p 6= r maintains an additional state allowing p to have Pp as current successor. This is due to the fact that no processor (6= r) knows which of its neighbor is its parent Pp (the tree has no sense of direction), and every processor p (including the leaf processor) executes the same program (the algorithm is a weak semi-uniform algorithm). So, in an abnormal configuration, a processor p 6= r can have Pp as current
Time and Space Optimality of Depth-First Token Circulation
11
successor, every processor p (including r) can be the current successor of several of its neighbors and, cycles may exist, i.e., pairs of neighbors f p; qg such that q is the current successor of p while p is the current successor of q (S p = q ^ Sq = p). Every processor p 6= r locally refers to the set of its predecessor as Pred p . Every cycle f p; qg is free if Pred p = fqg^ Predq = f pg, otherwise f p; qg is connected. Moreover, a connected cycle f p; qg is 2-connected if jPred p j > 1 and jPredq j > 1, i.e., both p and q have a predecessor which is not into the cycle. A connected cycle not being 2-connected is 1-connected. To be snap-stabilizing, Algorithm 2 must remove all abnormal local configuration without interfering with the normal DFTC cycle. That is the aim of Action OC. With that action, the false roots are removed similarly as in Algorithm T C SoD , i.e., every illegal root is shifted until the sequence of successors starting from it eventually disappears. Since, every false root eventually disappears, every 2-connected cycle eventually becomes either free or 1-connected (At least one false root is removed), even if it is created by two neighbors holding a token, and choosing each other as successor. (At least one false root is removed.) Algorithm 2 removes cycles once they are free or 1-connected: A processor p being in a cycle f p; qg such that Pred p = fqg becomes idle executing Action OC. If the sequence of successors starting from the root r ends with a cycle, then that cycle is eventually 1-connected because the false roots connected to that cycle eventually disappear. In that case, after the execution of Action OC, it is easy to observe that the normal DFTC cycle behaves correctly, i.e., as if the abnormal configurations never existed. The following result follows from Algorithm T C nSoD and Theorem 6: Theorem 7 Algorithm T C nSoD is optimal in terms of the number of states per processor to implement the weak semi-uniform DFTC cycle on a tree network having no sense of direction. Algorithm T C nSoD is Snap-Stabilizing. In the following, we use the notation f p; qg; γ) ` fFree; 2C-; 1C-gCycle to indicate that the cycle f p; qg is a free, 2connected, or 1-connected cycle in configuration γ. FRγ and FCγ denote the number of false roots and the number of free cycles in configuration γ, respectively. Let Fγ be the value FRγ + FCγ . We will now show that all abnormal local configurations eventually disappear, i.e., Fγ is eventually equal to 0 forever. The following lemma shows that a processor p can become a false root only when either every predecessor of p is a false root, or p is in a free cycle or in a 1-connected cycle such that every processor not involved in the cycle is a false root. (
Lemma 2 8 p 6= r : 8α; β 2 C : α 7! β :: ( p; α) 6` FalseRoot ^ ( p; β) ` FalseRoot ) / in α) ^ (Pred p 6= 0
Distributed Data and Structures 2
12
8q 2 Pred p in α : (Sq = idle in β) ^ ` FalseRoot _ (f p qg α) ` FreeCycle _ (f p qg α) ` 1C-Cycle)).
(
((q; α)
;
;
;
;
Proof. We prove this by contradiction. First of all, p cannot be done in α because no action allows p to be a false root in β (p can execute O2 only). By contradiction, we have the following cases: (1) Pred p = 0/ in α, (2) 9q 2 Pred p in α : Sq 6= idle in β, (3) 9q 2 Pred p in α :: (q; α) 6` FalseRoot ^ (f p; qg; α) 6` FreeCycle ^ (f p; qg; α) 6` 1C-Cycle. Assume that Pred p = 0/ in α (1). Then, p can execute Action OC only. So, ( p; β) 6` FalseRoot which contradicts the assumption. Assume that 9q 2 Pred p in α : Sq 6= idle in β (2). So, Sq = done or Sq = p0 in β 0 (p 2 Nq ). In both cases, that implies that q executed O1 in α and, then, S p = done in α, which is impossible. Assume that 9q 2 Pred p in α :: (q; α) 6` FalseRoot ^ (f p; qg; α) 6` FreeCycle ^ / and either p 62 Predq , or (f p; qg; α) ` (f p; qg; α) 6` 1C-Cycle (3). So, Predq 6= 0 2C-Cycle. In that cases, q can execute an action only if S p = done, which is impossible. 2 Lemma 2 implies that if a processor becomes a false root, then it replaces at least another false root or a free cycle disappeared. Moreover, Algorithm T C nSoD can create free cycles only by removing at least one false root. So, the following result follows from Lemma 2: Lemma 3
8α β 2 C : α 7! β :: Fα Fβ . ;
Theorem 8 All false roots and free cycles eventually disappear in O(h) steps. Proof Outline. Since the tree networks we consider are tree without sense of direction, in the worst case, the longest sequence of successors rooted at a false root is bounded by 2h. (The sequence starts at a false root which is a leaf processor, goes up in the neighboring of the root, and, goes down to a leaf processor.) By successive executions of Action OC, such a false root disappear in O(h) steps. A free cycle f p; qg either disappears in 1 step (both p and q execute Action OC in the same step), or creates a new false root. Also, by successive executions of Action OC, that false root disappear in O(h) steps. Finally, two sequences of successors may create a new 2-connected cycle (the extremities of both sequences are neighbors and choose each other as current successor). Then, there are two cases: (1) both sequences are rooted in a false root, or (2) one of the two sequences is rooted in r. In the first case, that 2-connected cycle eventually becomes a free cycle or 1-connected cycle. In the second case, the sequence rooted in r eventually ends by a 1-connected cycle. In both cases, cycles and false roots disappear in O(h) steps (again, by successive Action OC).
2
Once no false root and no free cycle exists, no abnormal local configuration remains in the system except that the sequence of successors starting from the
Time and Space Optimality of Depth-First Token Circulation
13
root may ends with a 1-connected cycle. But, then, the processor having only one predecessor eventually executes Action OC, updating its state to idle. Then, the current normal DFTC cycle continues without any perturbation. That and Theorem 8 leads to the following theorem: Theorem 9 (snap-stabilizing) Algorithm T C nSoD is a snap-stabilizing DFTC scheme. Now, let us consider the worst delay of the first DFTC cycle of Algorithm
T C nSoD . Consider p be the processor of the normal DFTC cycle having the token, i.e., Forward ( p) or Backward ( p) is true. Assume that Processor q = Next p is involved in in a sequence of successors rooted at a false root. So, p is not enabled while Next p (q) is not in state idle. We shown in Theorem 8 that, in the worst case, the longest sequence of successors rooted at a false root is when the false root is a leaf processor. In that case, p has to wait that q executes Action OC change its state from Sq = q0 (q0 2 Nq ) to idle. That takes at most h steps (by successive executions of Action OC when p = r). Next, the normal DFTC cycle (i.e., the sequence rooted in r) will follows the false root shifted down toward the leaves, until the false root reaches a leaf and disappears. Hence: Theorem 10 The delay to start the first DFTC cycle using Algorithm T C nSoD is bounded by O(h) steps.
4 Optimality In General Networks Some self-stabilizing depth-first token circulation algorithms exist for arbitrary rooted networks, i.e., these algorithms do not assume the existence of a spanning tree. We present a new concept, called the reading radius [12], as another parameter to compare different algorithms in the state model. We define the reading radius of a processor i as the maximum distance (in terms of hops) of any processor j from i such that i can read the state of j. Obviously, most of algorithms written in the state model assume that the reading radius is equal to 1, i.e., every processor can read its own state and the state of its neighbors only. However, we observed that some algorithms written for some special networks (as in [6] and [9]) can also be considered as algorithms for rings or chains, if the reading radius is assumed to be greater than one. The first solution to the depth-first token circulation in general networks allowing less than O(n) states per processor in [10] (n is the number of processors of the system) also assumed a reading radius equal to 2. Based on the same assumption of the reading radius equal to 2, we propose in [13] a self-stabilizing depth-first token circulation algorithm for arbitrary rooted network. This algorithm requires only 2 (∆ p + 1) states per processor p. Then we assume a reading radius equal to 1 (i.e., the common assumption), and present
14
Distributed Data and Structures 2
in [5] an algorithm for arbitrary networks requiring only 3 (∆i + 1) states per processor (2(∆i + 1) on the root). This is the best known result for this problem assuming a reading radius equal to 1. An open question is “What is the optimality in terms of the number of states per processor for the general networks?” What is the interest in studying such an assumption – a reading radius greater than one? The main benefit is to gain a deep understanding of the mechanism to design efficient algorithms. As an evidence of this fact, we present in [14] a selfstabilizing depth-first token circulation for the general message-passing networks. This algorithm is an adaptation of the corresponding algorithm in the state model assuming a reading radius of 2 ([13]). It uses our previous result which was designed in the state model with the reading radius of 2. It allows a message size of 5 bits only. Moreover, Dolev, Israeli, and Moran [4] showed that, for many applications, assuming unbounded channels, it is not possible to compute the message complexity before stabilization. The depth-first token circulation is one of those problems. However, an interesting issue is the additional cost in terms of the number of messages used after stabilization. The message complexity of the proposed algorithm is O (∆m), where ∆ is the maximum degree and m is the number of links in the network. Since for most networks, ∆ m, this message complexity matches that of the classical non-self-stabilizing algorithms, i.e., O (m). Hence, the algorithm proposed in [14] is asymptotically optimal for the message size and quite asymptotically optimal for the number of messages.
5 Conclusion We proposed two depth-first token circulation algorithms for rooted tree networks. The former works on trees having a (minimal) sense of direction, the latter works on trees without any sense of direction. Both are time (snap-stabilizing) and state optimal. Then, we investigated the optimality of the depth-first token circulation in arbitrary rooted networks. We presented several algorithms. Some of them are asymptotically optimal in terms of states per processor. Some other works are in the message-passing model with messages of size 5 bits. The number of messages required for that last algorithms after stabilization is very closed to the optimal number of messages for the depth-first token circulation.
References [1] A Bui, AK Datta, F Petit, and V Villain. State-optimal snap-stabilizing PIF in tree networks. In Proceedings of the Fourth Workshop on Self-Stabilizing Systems, pages 78–85. IEEE Computer Society Press, 1999. [2] EW Dijkstra. Self stabilizing systems in spite of distributed control. Communications of the Association of the Computing Machinery, 17:643–644, 1974.
Time and Space Optimality of Depth-First Token Circulation
15
[3] S Dolev, A Israeli, and S Moran. Self-stabilization of dynamic systems assuming only read/write atomicity. Distributed Computing, 7:3–16, 1993. [4] S Dolev, A Israeli, and S Moran. Resource bounds for self-stabilizing message-driven protocols. SIAM Journal on Computing, 26:273–290, 1997. [5] AK Datta, C Johnen, F Petit, and V Villain. Self-stabilizing depth-first token circulation in arbitrary rooted networks. In SIROCCO’98, The 5th International Colloquium On Structural Information and Communication Complexity Proceedings, pages 229– 243, 1998. [6] M Flatebo and AK Datta. Two-state self-stabilizing algorithms for token rings. IEEE Transactions on Software Engineering, 20:500–504, 1994. [7] P Flocchini, B Mans, and N Santoro. Sense of direction: Definitions and properties. In SIROCCO’94 1st International Colloquium on Structural Information and Communication Complexity, pages 9–34, 1994. [8] MG Gouda and FF Haddix. The stabilizing token ring in three bits. Journal of Parallel and Distributed Computing, 35:43–48, 1996. [9] S Ghosh. Binary self-stabilization in distributed systems. Information Processing Letters, 40:153–159, 1991. [10] C Johnen and J Beauquier. Space-efficient distributed self-stabilizing depth-first token circulation. In Proceedings of the Second Workshop on Self-Stabilizing Systems, pages 4.1–4.15, 1995. [11] F Petit. Highly space-efficient self-stabilizing depth-first token circulation for trees. In OPODIS’97, International Conference On Principles Of Distributed Systems Proceedings, pages 221–235, 1997. [12] F Petit. Efficiency and Simplicity in Self-Stabilizing Distributed Depth-First Token Circulation Algorithms. PhD thesis, TR98-05, LaRIA, Universit´e de Picardie Jules Verne, Amiens France, 1998. [13] F Petit and V Villain. Color optimal self-stabilizing depth-first token circulation. In ISPAN’97, Third International Symposium on Parallel Architectures, Algorithms and Networks Proceedings, pages 317–323. IEEE Computer Society Press, 1997. [14] F Petit and V Villain. Color optimal self-stabilizing depth-first token circulation protocol for asynchronous message-passing systems. In PDCS-97 10th International Conference on Parallel and Distributed Computing Systems Proceedings, pages 227– 233. International Society for Computers and Their Applications, 1997. [15] F Petit and V Villain. Optimality and self-stabilization in rooted tree networks. Parallel Processing Letters, 1999. To appear. [16] M Tchuente. Sur l’auto-stabilisation dans un r´eseau d’ordinateurs. RAIRO Informatique Theoretique, 15:47–66, 1981. [17] V Villain. A new lower bound for self-stabilizing mutual exclusion algorithms. Technical Report RR97-17, LaRIA, University of Picardie Jules Verne, 1997. [18] V Villain. New tool and lower bounds of self-stabilizing mutual exclusion. Technical Report RR98-08, LaRIA, University of Picardie Jules Verne, 1998. Also presented at Dagstuhl Workshop on Self-Stabilization, August 17-21, 1998, Germany.