Developing Self-Stabilizing Coloring Algorithms ... - Semantic Scholar

17 downloads 0 Views 149KB Size Report
evaluates to true. The action part of a rule can be executed only if the rule is enabled. If two or more. 1. hpreconditioni! hactioni;. 2. 2. hpreconditioni! hactioni; ... 2.
Developing Self-Stabilizing Coloring Algorithms via Systematic Randomization (Extended Abstract) Sandeep K. Shukla

Daniel J. Rosenkrantz

S. S. Ravi

Department of Computer Science University at Albany { State University of New York Albany, NY 12222 Email: fsandeep, djr, [email protected]

Abstract We consider the problem of designing uniform selfstabilizing distributed algorithms for coloring chains and oriented rings. We provide deterministic uniform self-stabilizing algorithms for some of the problems, and impossibility results for the other problems. For problems in the latter class, we present randomized self-stabilizing algorithms. These results lead to a general method for obtaining randomized selfstabilizing algorithms.

1 Introduction and summary of results Self-stabilizing protocols (or algorithms) provide an important method for tolerating transient faults in a distributed system. Informally, a self-stabilizing protocol ensures that if a transient fault causes a distributed system to enter an inconsistent state, the system will recover to a consistent global state within a bounded amount of time. An important advantage of a self-stabilizing protocol is that it allows a distributed system to start from an arbitrary (possibly inconsistent) state. The concept of self-stabilization was introduced by Dijkstra [5], and has since been studied by a number of researchers (see for example, [9, 17] and the references contained therein). A protocol is uniform if all the processors constituting the distributed system execute the same program. For many important problems (e.g., mutual exclusion in a token ring, leader election in a  This research was supportedby NSF Grants CCR-90-06396 and CCR-94-406611.

ring, etc.) deterministic uniform self-stabilizing protocols are provably impossible due to the diculties encountered in deterministic symmetry breaking [2, 16]. Known uniform self-stabilizing protocols for these problems either use special assumptions about the distributed system (e.g., unique processor identi ers) or resort to randomization. The randomized solutions proposed in the literature appear to be problem speci c. Hence it is of interest to devise a general method for systematically introducing randomization to obtain uniform self-stabilizing protocols. This paper presents one such method. We consider the problem of designing uniform selfstabilizing protocols for coloring rings and chains. These problems are considered under three models for selecting the set of processors which will execute during a time step. The three processor selection models are central daemon (where a central scheduler selects one of the enabled processors at each step), restricted parallelism (where there is a speci ed restriction on the set of processors that may execute at each step), and maximal parallelism (where all enabled processors may execute at each step). Our results are summarized below. 1. We present a deterministic uniform protocol for coloring the nodes of a chain with two colors. For odd chains (i.e., chains containing an odd number of nodes), we prove that this protocol achieves selfstabilization under any of the three processor selection models. For even chains, we prove that this protocol achieves self-stabilization under the central daemon and restricted parallelism models. We also observe that no deterministic uniform self-stabilizing protocol is possible for coloring an even chain with two colors under the maximal parallelism model. However, the correctness of our protocol under the restricted par-

allelism model allows us to deduce that our protocol achieves self-stabilization under the maximal parallelism model with probability 1. 2. We prove that it is impossible to design a deterministic uniform self-stabilizing protocol for coloring the nodes of an oriented even ring with two colors. However, using a result in [13], we devise a randomized uniform self-stabilizing protocol for this problem. 3. We present a deterministic uniform self-stabilizing protocol for coloring the nodes of any ring with three colors. We prove the correctness of this protocol under two models, namely central daemon and restricted parallelism. It is easy to see that no deterministic uniform self-stabilizing protocol is possible for this problem under maximal parallelism. As before, the correctness of our protocol under restricted parallelism allows us to deduce that our protocol achieves selfstabilization under maximal parallelism with probability 1. Thus, our results suggest a general technique for introducing randomization to achieve self-stabilization under the maximal parallelism model. We consider this general technique as the main contribution of the paper. In this extended abstract, proofs are omitted due to space limitations. Detailed proofs will be included in a complete version of this paper.

2 The model A distributed system consists of a collection of processors (or processes) communicating through a network. The network is represented as an undirected graph ( ) in which each node represents a processor and each edge represents a communication or logical link between between a pair of processors. Henceforth, we use \processor" and \node" interchangeably. A distributed algorithm is generally described by specifying the program to be run by each processor. When each processor executes the same program (i.e., in the case of a uniform algorithm), the program executed by a typical processor is speci ed. The syntax for a program executed by any node is shown in Figure 1. This syntax follows the guarded command notation introduced by Dijkstra [6]. We follow the terminology of [5] and refer to each statement as a rule. The rules are numbered for convenience. The semantics of this notation are as follows. We say that a rule is enabled if the precondition part of the rule evaluates to true. The action part of a rule can be executed only if the rule is enabled. If two or more G V; E

Pi

1. hpreconditioni! hactioni; 2 2. hpreconditioni! hactioni; .. . 2 . hpreconditioni! hactioni;

r

Figure 1: Syntax for the program executed by any processor rules of a program are simultaneously enabled, then the action part corresponding to one of the enabled rules is chosen for execution nondeterministically. We say that a processor is enabled if at least one of the rules in the program to be executed by the processor is enabled; otherwise, the processor is said to be disabled. The preconditions are Boolean functions of the state of a processor and the states of its neighbors. If the value of a precondition depends on the outcome of a random experiment (e.g. coin toss, generating a random number, etc.), then we say that the algorithm is randomized. If all the preconditions can be evaluated deterministically, then we say that the algorithm is deterministic. For many problems, (e.g. leader election in a ring [16]) deterministic selfstabilizing algorithms are provably impossible. For such problems, it is of interest to investigate whether there are randomized algorithms which achieve selfstabilization with high probability. It is assumed that each processor has knowledge of its neighbors and that the neighborhood information is not corrupted even in the presence of transient faults. This is not an unreasonable assumption because the neighborhood information can be hardwired. We also assume that a processor can read the states of its neighbors in one atomic operation. Further, the execution of the action corresponding to the selected (enabled) rule is also atomic. In other words, when a processor is scheduled to execute, it reads the state variables of its neighbors, computes the preconditions, and if any of the preconditions is true, it executes the action part of some enabled rule, all in one atomic step. In some literature (for example [14]), this is referred to as the state-reading model of program execution. An alternative is the link-register model used in [8, 15]. All the results presented in this paper, apply only to the state-reading model. We also assume that the system is anonymous;

that is, none of the processors has an identi cation (id) number. (In our correctness proofs, we often refer to the processors by numbers, but that is just for notational convenience.) In distributed systems where processors have unique id's, it is often easier to design distributed algorithms. (However, this is not always the case [16].) Designing distributed algorithms for anonymous networks of processors is more challenging. All the problems considered in this paper are for anonymous networks. We consider three di erent models for selecting the processors which will execute during a time step. (In the literature, such a model is also referred to as an adversary [17].) We refer to these processor selection models as central daemon, maximal parallelism (or distributed daemon) and restricted parallelism respectively. The central daemon model, where a central scheduler selects one processor for every time step, is similar to that used in [5]. The maximal parallelism model refers to the scheduling strategy where all the enabled processors may execute in parallel. In the restricted parallelism model, when two or more processors are simultaneously enabled, only a proper subset of these may execute. This last model has not been studied in the literature explicitly. This is a fairly restrictive model and is dicult to implement. However, as will be apparent from the results presented in this paper, this conceptual model facilitates the design of randomized self-stabilizing protocols under the maximal parallelism model. Often, it is also more dicult to design uniform distributed algorithms for problems. It is known that for several problems there are no deterministic uniform self-stabilizing algorithms under any of the processor selection models [2, 4, 7, 9]. For all the problems considered in this paper, we present deterministic uniform self-stabilizing algorithms, whenever such algorithms exist. For some of these problems, we show that it is not possible to design deterministic uniform self-stabilizing algorithms. In such cases, we present randomized algorithms that achieve self-stabilization with probability 1.

3 Self-stabilization As mentioned earlier, a self-stabilizing system is one that is robust in the face of transient faults and arbitrary initialization. The concept of self-stabilization was introduced by Dijkstra in [5]. His de nition was based on classifying each global state of a distributed system executing a certain algorithm as either a legal (or legitimate) state or as an illegal (or illegit-

imate) state. Consider, for example, a distributed

system executing an algorithm that produces a valid coloring of the nodes of the network (i.e., each node is assigned a color and adjacent nodes receive di erent colors). For this example, the legal global states are those in which the coloring is valid. An illegal global state is one in which there is at least one node which has not been assigned a color or there is at least one pair of adjacent nodes which are assigned the same color. After the algorithm produces a valid coloring of the nodes, a transient fault may change the colors assigned to the nodes, thus causing the system to enter an illegal state. A self-stabilizing coloring algorithm is required to bring the system back to a legal state in a nite number of steps. Also note that, in general, the initial global state of the system may be an illegal state. Thus the coloring algorithm is required to work correctly regardless of the initial state of the system. When the system states are classi ed as above, the notion of a self-stabilizing algorithm may be de ned as follows. A self-stabilizing distributed algorithm recovers from an illegitimate global state to a legitimate global state in a bounded amount of time with no external intervention. Throughout this paper, we will use this de nition of a self-stabilizing algorithm. Another way of de ning a self-stabilizing distributed algorithm is in terms of behavior sequences, as discussed in [18]. In the distributed paradigm, self-stabilization is gaining increasing attention because it provides a formal and uni ed view of fault tolerance [17]. A number of recent papers have developed self-stabilizing algorithms for a variety of problems [1, 3, 10, 11, 14, 15]. It is easy to see that if an algorithm can be shown to be self-stabilizing under the subset restriction model it is also self-stabilizing under the central deamon model. However, that is not the case with the pairing restriction model. In the cases where we prove correctness under the subset restriction model, we donot need to prove it under central deamon. But for algorithms which we prove to be correct under pairing restricted parallelism, we give separate proves for their correctness under central deamon.

4 The problem Vertex coloring is a well studied problem in graph theory [12]. Given a graph ( ) and an integer , the goal of the -coloring problem is to assign a color to each node of such that such that no two adjacent nodes are of the same color and the number G V; E

K

K

G

of colors used is at most , if such a coloring exists. Throughout this paper, we assume that the graph to be colored is the network interconnecting the processors. The graphs considered in this paper are chains (i.e., the nodes and edges of the graph form a simple path) and oriented rings (i.e., the nodes and edges of the graph form a simple directed cycle). For all the problems considered in this paper, the graph and the value of are such that a valid -coloring is always possible. The goal is to develop a uniform self-stabilizing distributed algorithm that produces a valid -coloring. Coloring problems in distributed systems are useful in achieving certain types of mutual exclusion. For example, suppose that no two adjacent nodes should have access to some resource at the same time. By rst producing a valid coloring of the network and then assigning the same resource only to processors of the same color, one can implement this form of mutual exclusion. Ghosh and Karaata [11] present a deterministic uniform self-stabilizing algorithm that colors planar graphs using 6 colors. Their algorithm is for systems in which nodes have distinct id's. The algorithms presented in our paper do not rely on distinct node id's. Further, in our algorithms, the nodes need not know the size (i.e., the total number of nodes) in the system. Thus, our algorithms are suitable even for systems whose sizes vary with time because of addition or deletion of nodes. K

K

1. h ^ 6= 0i ! h := 0i; 2 2. hnot( ) ^ 6= min( ( 1 ) ( 2 )) + 1i ! h := min( ( 1 ) ( 2 )) + 1i; EN D

X

X

EN D

X

X N

X

X N

;X N

;X N

Figure 2: Program for a typical Processor in Algorithm A

K

K

5 Self-stabilizing 2-coloring for chains Let us denote the two colors by 0 and 1. We begin by observing that if the chain is oriented (i.e., each edge has a direction and the graph is a simple directed path), then the following simple uniform algorithm produces a valid 2-coloring and is selfstabilizing: Each processor tests if it has a left neighbor. If yes, then it will read the color of the left neighbor and change its own color to the complement of the neighbor's color; otherwise, the processor sets its color to 0. The correctness of this algorithm is clear from the following facts. The leftmost processor (i.e., the processor with no incoming edges) stabilizes with color 0 and never changes. Once a given processor stabilizes with a given color, its right neighbor will stabilize with the other color. Now we assume that the chain is unoriented. We rst consider the case of odd chains. We assume that a typical processor in the chain can test a (hard wired)

Boolean predicate which is true if that processor has only one neighbor. Thus, this predicate is true only for the two processors at the two ends of the chain. We also assume that each processor has a local variable which can take nonnegative integer values. The color of a processor is another local variable in that processor. In the presentation of the algorithms we represent the two neighbors of a node as 1 and 2 if it has two neighbors. For an end node we denote its only neighbor as 1 . Any local variable in 1 such as in 1 is referred to as ( 1 ) and so is for 2 . Note that we are not assuming any node ids or orientation. But locally each node can distinguish between its two neighbors through the access ports. Figure 2 presents Algorithm A which produces a valid 2-coloring and is self-stabilizing for odd chains. Assuming that for each processor = mod 2 it can be shown by a careful inductive argument that under any of the processor selection models, an odd chain stabilizes at the con guration in which the two end nodes have color 0, the two nodes at a distance of 1 from either end node have color 1, etc., and the middle node (there is a unique middle node since the chain has an odd number of nodes) has a color which is the complement of either of its neighbors. EN D

X

C

N

N

N

N

X

N

X N

N

C

X

Theorem 5.1 For any odd chain, Algorithm A produces a valid 2-coloring and is self-stabilizing under all processor selection models under consideration. 2 When we apply Algorithm A to even chains, the nal con guration reached (i.e., when all the processors are disabled) is not a valid 2-coloring. This is because an even chain has two middle nodes which are adjacent, and these two nodes are assigned the same color in the nal con guration. This raises the question of whether there is a uniform self-stabilizing algorithm for this case. The following theorem presents a negative result for the maximal parallelism model. This theorem is proven by constructing for any uniform algorithm, a nite number of invalid 2-coloring con gurations through which the system can be made to cycle under maximal parallelism.

1. h( ( 1 ) ) ^ ( 6= ( 1 )) i! h := i; 2 2. h( ( 2 ) ) ^ ( 6= ( 2 )) i! h := i; 2 3.hnot( ) ^ ( ( 1 ) = ) ^ ( = ( 1 )) i ! h := i; 2 4. hnot( ) ^ ( ( 2 ) = ) ^ ( = ( 2 )) i ! h := i; 2 5. h 6= ( + ) mod 2 i ! h := ( + 1) mod 2 i X N

> X

S

S N

S

S

X N

> X

S

S N

S

S

EN D

X N

S

EN D S

C

X

X

S

S N

S

X N

X

S

S N

S

S

C

C

Figure 3: Program for a typical Processor in Algorithm A+

Theorem 5.2 There is no deterministic uniform self-stabilizing 2-coloring algorithm for unoriented even chains under the maximal parallelism model. 2

In contrast to the above negative result, we now present a uniform self-stabilizing 2-coloring algorithm for even chains under the central daemon and pairing restricted parallelism models. Consider the algorithm A+ shown in Figure 3. In that gure, we have introduced a new Boolean variable for each processor. We assume that using some type casting this variable S can be treated as an integer so that the addition operation in the 5th rule is type correct. It can be shown that when A+ is started with the nal con guration produced by Algorithm A, then the system stabilizes at a valid 2-coloring under the pairing restricted parallelism model (and also the central daemon model). As a consequence, a fair composition [15] of Algorithms A and A+ yields a uniform self-stabilizing 2-coloring algorithm for chains of arbitrary size under the pairing restricted parallelism and the central daemon models. The pairing restriction in this case is that the two central nodes in the even chain do not execute together in any time step. S

Theorem 5.3 There is a deterministic uniform self-

stabilizing 2-coloring algorithm for unoriented chains under the central daemon and pairing restricted parallelism models. 2

The fact that there is a uniform deterministic selfstabilizing 2-coloring algorithm for chains under the pairing restricted parallelism model enables us to obtain a randomized self-stabilizing 2-coloring algorithm for chains under the maximal parallelism model. This

result complements the negative result for deterministic algorithms under the maximal parallelism model (Theorem 5.2). This randomized algorithm is obtained by a simple modi cation of the algorithm of Theorem 5.3. We assume that each processor has a random bit generator that produces a 0 with probability and a 1 with probability 1 ? for some , 0 1. In each step, a processor rst generates this random bit and executes the action part of some enabled rule only if the randomly generated bit value is 1. If the random bit value is 0, the processor does not execute. It is possible to argue that under maximal parallelism, this strategy breaks symmetry with probability 1 and hence the system stabilizes with probability 1. r

r

r

< r