Some Modifications of the Tournament Algorithm ... - Semantic Scholar

1 downloads 0 Views 227KB Size Report
SYST., VOL.E82–D, NO.2 FEBRUARY 1999. PAPER. Some Modifications of the Tournament Algorithm for the. Mutual Exclusion Problem. Yoshihide IGARASHI.
IEICE TRANS. INF. & SYST., VOL.E82–D, NO.2 FEBRUARY 1999

368

PAPER

Some Modifications of the Tournament Algorithm for the Mutual Exclusion Problem Yoshihide IGARASHI† , Member, Hironobu KURUMAZAKI† , Nonmember, and Yasuaki NISHITANI† , Member

SUMMARY We propose two lockout-free (starvation-free) mutual exclusion algorithms for the asynchronous multiwriter/reader shared memory model. The first algorithm is a modification of the well-known tournament algorithm for the mutual exclusion problem. By the modification we can speed up the original algorithm. The running time of the modified algorithm from the entrance of the trying region to the entrance of the critical region is at most (n − 1)c + O(nl), where n is the number of processes, l is an upper bound on the time between successive two steps of each process, and c is is an upper bound on the time that any user spends in the critical region. The second algorithm is a further modification of the first algorithm. It is designed so that some processes have an advantage of access to the resource over other processes. key words: asynchronous processes, concurrency, distributed systems, lockout-freedom, mutual exclusion, shared memory

1.

Introduction

Mutual exclusion is a problem of managing access to a single indivisible resource that can only support one user at a time. An early algorithm for the mutual exclusion problem was proposed by Dijkstra [6]. The original version of the Dijkstra’s algorithm was presented on a model assuming a shared memory with atomic read and write operations. The Dijkstra’s algorithm guarantees mutual exclusion, but it does not guarantee high-level fairness. Subsequent algorithms are improvements on the Dijkstra’s algorithm by guaranteeing fairness to the different users [15], [16], weakening the type of shared memory [1]–[3], [5], [7]–[10], or describing algorithms in more clearly specified shared memory models [9], [12], [13]. The tournament algorithm for the mutual exclusion problem is originated from the tournament protocol of Peterson and Fisher [16]. Since the shared memory model used in the tournament protocol is not clear enough to analyze its running time, we use the tournament algorithm described in terms of I/O automata in the asynchronous multi-writer/reader shared memory model [12]. An I/O automaton models a distributed system component that can interact with other system components. It is a simple type of state machine. The transitions of an I/O automaton are associated with Manuscript received June 15, 1998. Manuscript revised September 14, 1998. † The authors are with the Faculty of Engineering, Gunma University, Kiryu-shi, 376–8515 Japan.

actions which are classified input, output, or internal actions. Some modifications of the tournament algorithm have been proposed [4], [11], [17]. The algorithm of Lamport in [11] was designed so that the running time is small in the case where the degree of contention (i.e., the number of processes in the trying region in a time) is small. The algorithm of Lamport [11] is not lockout-free, and the algorithms in [4], [14], [17] are some improvements over the Lamport’s one. In this paper we propose some modifications of the tournament algorithm in the asynchronous multiwriter/reader shared memory model specified in [12]. Each process in the distributed system is modeled as an I/O automaton whose transitions are associated with its own internal actions, output actions to other components, or input actions from other components. The interactions of each process with shared variables are possible only by actions of reading the contents of a shared variable or writing a value into a shared variable. Note that read-modified-write shared memory [12] is another shared memory model which is different from the model considered in this paper. The first modification is to improve the time that any user spends in the trying region. An upper bound on the running time for the trying region of the modified algorithm for n processes is (n − 1)c + O(nl), where l is an upper bound on the time between successive two atomic actions of any process during the execution of the trying region or the exit region, and c is an upper bound on the time that any user spends in the critical region (i.e., the duration of keeping the resource by a process). The corresponding running time of the tournament algorithm on the same multi-writer/reader shared memory model given in [12] is (n − 1)c + O(n2 l). This shows that our algorithm given in this paper is good at speed compared with the original tournament algorithm. There may be a natural request to design a distributed operating system such that the access to the resource by some processes are easier than by other processes. For this purpose we make a further modification to the algorithm so that some processes have an advantage of access to the resource over other processes. The lockout freedom of the second modified algorithm is also proved by showing an upper bound on the running time for the trying region.

IGARASHI et al: SOME MODIFICATIONS OF THE TOURNAMENT ALGORITHM FOR THE MUTUAL EXCLUSION PROBLEM

369

2.

Preliminary

The asynchronous model used in this paper is a collection of processes and multi-writer/reader shared variables as depicted in Fig. 1. Interactions between a process and its corresponding user are by input actions from the user to the process and by output actions from the process to the user. Each process is considered to be a state machine with arrows entering and leaving the process, representing its input and output actions. All communication among the processes is via the shared memory. In one step concerned with shared variables, a process can either read or write a single shared variable, but not both. This model can be expressed as an I/O automaton. An input action to a process from the corresponding user, an output action of a process to the corresponding user, setting the contents of a shared variable by a process (with or without local operations), and reading the contents of a shared variable by a process (with or without local operations), are considered to be atomic actions of the process. There may exist concurrency of reading or writing a shared variable by several processes. However, we assume that those actions to a shared variable can be serialized. That is, even though actions to a shared variable seem to be concurrent, the processes obtain responses that make it look like the accesses occur one at a time in some consistent sequential order. For example, even if two different processes try to write on the same shared variable at almost the same time, one process’s writing is earlier than the other process’s writing. In this case, the contents of the shared variable written by the earlier one is changed to the value written by the later one even if these two events occur very closely. In this paper we do not consider any other types of shared variables such as read-modify-write shared variables or shared variables with operations. The reader can find a complete and formal description of I/O automata in [12], [13].

Fig. 1 An asynchronous shared memory system with interactions between users and processes.

The mutual exclusion problem is how to allocate a single indivisible, nonsharable resource among n users. A user with access to the resource is modeled as being in a critical region. When a user is not involved in anyway with the resource, it is said to be in the remainder region. In order to gain admittance to its critical region, a user executes a trying protocol. The duration from the start of executing the trying protocol to the entrance of the critical region is called the trying region. After the end of the use of the resource by a user, it executes an exit protocol. The duration of executing the exit protocol is called the exit region. Each user follows a cycle, moving from its remainder region to its trying region, to its critical region, to its exit region, and then back again to its remainder region. The cycle can be repeated. We assume that the n processes are numbered 0, . . . , n − 1, each process i corresponding to user Ui (0 ≤ i ≤ n−1). The inputs to process i from user Ui are try i which means a request by Ui for access to the resource, and exit i which means an announcement of the end of the use of the resource by Ui . The outputs from process i to user Ui are crit i which means the grant of the resource to Ui , and rem i which tells Ui that it can continue with the rest of its work. These are external actions of the shared memory system. The system to solve the mutual exclusion problem should satisfy the following conditions. (1) There is no reachable system state in which more than one users are in the critical region. (2) If at least one user is in the trying region and no user is in the critical region, then at some later point some user enters the critical region. (3) If a user is in the exit region, then at some later point some user enters the remainder region. Conditions (1), (2) and (3) above are called mutual exclusion, progress for the trying region, and progress for the exit region, respectively. The Dijkstra’s mutual exclusion algorithm guarantees mutual exclusion and progress for both the trying region and the exit region [6]. However, it may allow one user to be repeatedly granted for access to its critical region while other users trying to gain access never succeed in doing so. This situation is called lockout or starvation. Lockout is an undesirable property. That is, such a situation is considered to be not fair to different users. If a mutual exclusion algorithm satisfies the following two conditions, it is said to be lockout-free or starvation-free. (1) If all users always return the resource, then any user that reaches the trying region eventually enters the critical region. (2) Any user that reaches the exit region eventually enters the remainder region.

IEICE TRANS. INF. & SYST., VOL.E82–D, NO.2 FEBRUARY 1999

370

3.

Speedup of the Tournament Algorithm

The tournament algorithm for the mutual exclusion problem is based on a combination of the ideas of the nprocess algorithm of Peterson [15] and the tournament protocol of Peterson and Fischer [16]. In this section we show a modification of the tournament algorithm and discuss its efficiency. In order to analyze the running time of the modified tournament algorithm and to compare its efficiency with the efficiency of the original tournament algorithm, we use the program described in terms of the I/O automata model given in [12]. For simplicity, we assume that the number of processes, n is a power of 2. The algorithm is described on the complete binary tree with n leaves, called an n-leaves tournament tree. The leaves of the complete binary tree are labeled as 0, . . . , n − 1 in binary representation from left to right. For each 0 ≤ i ≤ n − 1, process i is associated with the leaf with label i. All logarithms are to the base 2. Each internal node in depth k of the complete binary tree, 0 ≤ k ≤ log n−1, is labeled as the high-order k bits of the binary representation of any of its descendants. Note that the root of the tournament tree is labeled as λ, the null length string. The following notations will be used to describe the original tournament algorithm and the modified tournament algorithm on the n-leaves tournament tree. • comp(i, k) is the ancestor of i in depth k in the tournament tree (i.e., the high order k bits of the binary representation of i). Note that comp(i, log n) is the leaf associated with i. • role(i, k) is the (k + 1)st high-order bit of i (i.e., role(i, k) indicates whether the leaf i is a descendant of the left or right child of the node for comp(i, k)). • opponents(i, k) is the opponents of process i in the depth k competition of process i (i.e., the set of processes with the high-order k bits as i and the opposite (k + 1)st bit.) • opposite(i, k) is the son of comp(i, k) that is not an ancestor of i. Example 1: Consider an 8-leaves tournament tree as depicted in Fig. 2. For example, comp(6, 1) = 12 , role(6, 1) = 12 , opponents(6, 1) = {4, 5}, opposite(6, 1) = 102 , where r2 means that r is in binary representation. The following procedure, n-tournamentME is the tournament algorithm quoted from [12]. procedure n-tournamentME shared variables for every binary string x of length at most log n − 1:

Fig. 2

The tournament tree with 8 leaves.

turn(x) ∈ {0, 1}, initially arbitrary, writable and readable by those processes i for which x is a prefix of the binary representation of i; for every i, 0 ≤ i ≤ n − 1: f lag(i) ∈ {0, 1, . . . , log n}, initially log n, writable by i and readable by all j = i; process i: input actions { inputs to process i from user Ui }: try i , exit i ; output actions { outputs from process i to user Ui }: crit i , rem i ; ** Remainder region ** try i : for k = log n − 1 downto 0 do begin f lag(i) := k; turn(comp(i, k)) := role(i, k); waitfor [ ∀j ∈ opponents(i, k) : f lag(j) > k ] or [ turn(comp(i, k)) = role(i, k) ] end; crit i ; ** Critical region ** exit i : f lag(i) := log n; rem i ; Definition 1: For a mutual exclusion algorithm, let l be an upper bound on the time between successive two atomic actions of any process during the execution of the trying region or the exit region, and let c be an upper bound on the time that any user spends in the critical region. Theorem 1 ([12]): In n-tournamentME, the time from when a particular process i enters its trying region until it enters its critical region is at most (n − 1)c + O(n2 l). The following procedure, n-tournamentFME is a modification of n-tournamentME. For the modified tournament algorithm, each node of the n-leaves tournament tree, not only each leaf but also each internal

IGARASHI et al: SOME MODIFICATIONS OF THE TOURNAMENT ALGORITHM FOR THE MUTUAL EXCLUSION PROBLEM

371

node, is associated with a f lag variable. That is, it uses about twice as many f lag variables as f lag variables of n-tournamentME. However, each f lag variable as well as each turn variable of n-tournamentFME assumes only two values, 0 and 1. Hence, the total size of the shared variables of n-tournamentFME is 3n − 2 bits. On the other hand, the total size of the shared variables of n-tournamentME is n − 1 + n log(log n + 1) bits since each of its f lag variables assumes log n + 1 different values. procedure n-tournamentFME shared variables for every binary string x of length at most log n − 1: turn(x) ∈ {0, 1}, initially arbitrary, writable and readable by those processes i for which x is a prefix of i; for every binary string x of length at most log n: f lag(x) ∈ {0, 1}, initially 0, writable by those processes i for which x is a prefix of i, and readable by those processes for which i is a descendant of the parent of x but the i’s bit at the position corresponding to the last bit of x is opposite from x; process i: input/output actions: the same as the input/output actions of n-tournamentME ** Remainder region ** try i : for k = log n − 1 downto 0 do begin f lag(comp(i, k + 1)) := 1; turn(comp(i, k)) := role(i, k); waitfor [ f lag(opposite(i, k)) = 0 ] or [ turn(comp(i, k)) = role(i, k) ] end; crit i ; ** Critical region ** exit i : for k = 0 to log n − 1 do f lag(comp(i, k + 1)) := 0; rem i ; While a process i is executing the waitfor statement in the loop with k (i.e., (log n − k)th loop) in the trying region, the process i is said to be a competitor at comp(i, k). A process i is said to be a winner at comp(i, k) if the process i has left the loop with k in the trying region. Note that if process i is a winner at comp(i, k) then the process i is also a winner at comp(i, t) for every k ≤ t ≤ log n − 1. Assertion 1: In any reachable system state by ntournamentFME, for any i, 0 ≤ i ≤ n − 1, and any k, 0 ≤ k ≤ log n − 1, at most one process from the subtree rooted at comp(i, k) is a winner at comp(i, k).

Proof: The proof is an induction on the values for k (i.e., depth) of the complete binary tree. Basis: k = log n − 1. Suppose for the sake of contradiction that both process i and process j, j = opposite(i, log n − 1), are winners at comp(i, log n − 1) = comp(j, log n − 1). Then “turn(comp(i, log n − 1)) := role(i, log n − 1)” is executed earlier than “turn(comp(j, log n − 1)) := role(j, log n − 1),” or vice versa. Suppose that the former is executed earlier than the latter. Then during the execution of the waitfor statement by process j in the first loop in the trying region, turn(comp(j, log n − 1)) = role(j, log n − 1). Hence, in order that process j becomes a winner at comp(j, log n − 1), f lag(opposite(j, log n − 1)) = 0 should be satisfied at some point during the execution of the waitfor statement in the first loop in the trying region. Since we assume that “turn(comp(i, log n − 1)) := role(i, log n − 1)” is executed earlier than “turn(comp(j, log n − 1)) := role(j, log n − 1),” f lag(comp(i, log n)) = f lag(opposite(j, log n − 1)) has been set to 1 before the execution of the waitfor statement by process j in the first loop in the trying region. This is a contradiction. In the same way, we can lead a contradiction when “turn(comp(j, log n − 1)) := role(j, log n − 1)” is executed earlier than “turn(comp(i, log n − 1)) := role(i, log n − 1).” Induction step: We assume that the assertion holds for depth log n−1, . . . , k+2, k+1. Suppose for the sake of contradiction that there are two winners, process i and process j from the subtree rooted at comp(i, k), where comp(i, k) = comp(j, k), role(i, k) = 0 and role(j, k) = 1. Then process i and process j are also winners at comp(i, k + 1) and comp(j, k + 1), respectively. From the induction hypothesis, there are no winners other than process i at comp(i, k + 1) and no winners other than process j at comp(j, k + 1). Since both process i and process j are winners at comp(i, k), both “turn(comp(i, k)) := role(i, k)” and “turn(comp(j, k)) := role(j, k)” have been executed. Suppose that “turn(comp(i, k)) := role(i, k)” has been executed earlier than “turn(comp(j, k)) := role(j, k).” Since there are no other winners at comp(i, k), during the execution of the waitf or statement by process j, neither [f lag(opposite(j, k)) = 0] nor [turn(comp(j, k)) = role(i, k)] is satisfied. This is a contradiction. In the same way we can lead a contradiction in the case where “turn(comp(j, k)) := role(j, k)” has been executed earlier than “turn(comp(i, k)) := role(i, k).” Therefore, the assertion holds for any i, 0 ≤ i ≤ n − 1 and any k, 0 ≤ k ≤ log n − 1. ✷ Theorem 2: In n-tournamentFME, the time from when a particular process i enters its trying region until it enters its critical region is at most (n − 1)c + O(nl). Proof: Define T (log n) to be the maximum time from

IEICE TRANS. INF. & SYST., VOL.E82–D, NO.2 FEBRUARY 1999

372

when a process enters the trying region until it enters the critical region. For k, 0 ≤ k ≤ log n− 1, define T (k) to be the maximum time from when a process wins in depth k of the trying region until it enters the critical region. It is immediate that T (0) ≤ l. Consider a situation that process i has just entered the competition in depth k of the trying region. Let this event be denoted by π(i, k). In order to estimate an upper bound on T (k + 1), it is sufficient to consider the case where a competitor from opposite(i, k), say process s, becomes the first winner in the competition in depth k after π(i, k). The competitor, process s moves to the loop for k − 1 of the for statement in the trying region of process s within time 4l since the first two statements of the for statement are executed within time 2l and the third statement of the for statement is executed within time 2l (note that it requires at most time 2l since the waitf or statement contains two tests). The competitor, process s reaches the critical region within time T (k) after π(s, k −1). After spending at most time c in the critical region, process s enters its exit region. It takes at most time l for receiving the input exits and then it resets f lag(comp(s, k + 1)) (i.e., f lag(opposite(i, k)) to be 0 within time k+1 after receiving exits in the exit region. Hence, within at most time 4l + T (k) + c + (k + 2)l after π(i, k), f lag(opposite(i, k)) = 0 or turn(comp(i, k)) = role(i, k) is satisfied. Then within at most further time 2l, process i becomes a winner in depth k of the trying region. Hence, the maximum time from π(i, k) until process i reaches the entrance to the critical region is at most 2T (k) + c + (k + 8)l. Thus, we need to solve the following recurrence for T (log n). T (0) ≤ l, T (k + 1) ≤ 2T (k) + c + (k + 8)l = 2T (k) + (c + 7l) + (k + 1)l. Then we have the following inequality. T (log n) ≤ (1 + 2 + · · · + 2log n−1 )(c + 7l) +(2log n + 2log n−1 + 2 · 2log n−2 + · · · + (log n − 1) · 21 + log n · 20 )l ≤ (n − 1)c + O(nl). ✷ Note that n-tournamentFME is different from n-tournamentME at the first condition of the waitfor statement in the trying region and at the statement for resetting f lag values in the exit region. For n-tournamentFME, only one f lag variable (i.e., f lag(opposite(i, k))) is checked by process i in the waitfor statement in each loop with k, 0 ≤ k ≤ log n − 1, whereas for n-tournamentME, all f lag(x)’s, x ∈ opponents(i, k) are checked by process i in the waitfor statement in each loop with k, 0 ≤ k ≤ log n − 1.

The progress in the exit region of ntournamentFME is obvious. Hence, from Assertion 1 and Theorem 2, we have the following theorem. Theorem 3: n-tournamentFME solves the mutual exclusion problem and is lockout-free. 4.

Tournaments on Priority Trees

We modify the tournament algorithm given in the previous section so that some users have an advantage of access to the resource over some other users. A simple priority tree is a binary tree structure recursively defined as follows: (1) it consists of a single node, or (2) it is composed of three disjoint sets of nodes, a root node, a single node as its left subtree, and a simple priority tree as its right subtree. Each node of a binary tree is labeled by the following rules. (1) The root is labeled by λ (the null string). (2) If the label of a node x is l(x), the label of its left son is l(x)0 (i.e., the juxtaposition of l(x) and 0) and the label of its right son is l(x)1. According to the labeling rules above, the leaves of a simple priority tree with n leaves are labeled with 0, 10, 110, . . . , 1t−2 0, 1t−1 from left to right, and the internal node in depth k is labeled with 1k (1 ≤ k ≤ t − 2), where 1k denotes the juxtaposition of k 1s. Suppose that 2r+1 ≤ n. Let a = 2nr − 1 and  r = log2 (n − 2r a) . A priority tree T (n, r) is a binary tree constructed as follows: (1) Let Ts (n, r) be a simple priority tree with leaves labeled with 0, 10, . . . , 1a−1 0, 1a . (2) Each leaf of 0, 10, . . . , 1a−1 0 of Ts (n, r) is replaced with the complete binary tree with 2r leaves, and leaf 1a is replaced with an essentially complete binary tree with n − 2r a leaves. Each node of T (n, r) is labeled by the same rule as the labeling rule of the nodes of Ts (n, r). That is, the root of T (n, r) is labeled by λ, and if the label of node x is l(x), the label of its left son is l(x)0 and the label of its right son is l(x)1. We consider a one-to-one correspondence between the n processes and the n leaves of T (n, r). The label associated with a process in T (n, r) is called the index of the process. We denote the complete binary tree and the essentially complete binary tree that are replacements at the leaves of Ts (n, r) by G0 , G1 , . . . , Ga−1 and Ga from left to right. Hereafter, process i means a process of index i (see Fig. 3). This labeling of T (n, r) is consistent with the labeling of a complete binary tree defined in the previous section. Notations comp(i, k), role(i, k), and opposite(i, k)

IGARASHI et al: SOME MODIFICATIONS OF THE TOURNAMENT ALGORITHM FOR THE MUTUAL EXCLUSION PROBLEM

373

** Critical region ** exit i : for k = 0 to d(i) − 1 do f lag(comp(i, k + 1)) := 0; rem i ; Assertion 2: In any reachable system state by tournamentPME on T (n, r), and for any depth k, 0 ≤ k ≤ a+ r − 1, at most one process in depth k in any subtree rooted in depth k is a winner, where a = 2nr − 1 and r = log2 (n − 2r a) . Fig. 3

A priority tree.

are also used to describe the modified tournament algorithm on T (n, r). The meanings of these notations are the same as the corresponding notations given in the previous section. For simplicity we describe the algorithm on T (n, r) in the case where n = 2r (a + 1). With a minor modification we can also describe the algorithm for any pair of n and r such that n ≥ 2r+1 . The following procedure is obtained by modifying n-tournamentFME so that it can be used on T (n, r). procedure tournamentPME (n, r) { n = 2r (a + 1) } shared variables for every binary string x in the set of labels of T (n, r): turn(x) ∈ {0, 1}, initially arbitrary, writable and readable by those processes i for which x is a prefix of i; for every binary string x in the set of labels of T (n, r): f lag(x) ∈ {0, 1}, initially 0, writable by those processes i for which x is a prefix of i, and readable by those processes for which i is a descendant of the parent of x but the i’s bit at the position corresponding to the last bit of x is opposite from x; process i: { i is a leaf of Gt } input/output actions: the same as the input/output actions of n-tournamentME ** Remainder region ** try i : { d(i) = t + r + 1 if t ≤ a − 1, and otherwise d(i) = t + r } for k = d(i) − 1 downto 0 do begin f lag(comp(i, k + 1)) := 1; turn(comp(i, k)) := role(i, k); waitfor [ f lag(opposite(i, k)) = 0 ] or [ turn(comp(i, k)) = role(i, k) ] end; crit i ;

Proof: We use induction on the value of k. Basis: k is one level above the leaves under consideration. There are at most two processes associated with the children of any node just above the leaves. Suppose for the sake of contradiction that both the processes, i and j, allocated to the leaves with a common parent in depth k are winners in depth k. Then both the f lag values of process i and process j are set to 1. The first condition for waitfor is not satisfied for i and j. Hence, both turn(comp(i, k)) = role(i, k) and turn(comp(j, k) = role(j, k)) should be satisfied. However, this is not possible since “turn(comp(i, k)) := role(i, k)” and “turn(comp(j, k)) := role(j, k)” have been executed before executing waitfor in process i and waitfor in process j, respectively. Induction step: We assume that the statement for k holds true, and then we show that it holds for k − 1. Any winner in depth k − 1 is also a winner in depth k. Hence, from the induction hypothesis, there are at most two competitors in depth k − 1 of the subtree under consideration. Suppose for the sake of contradiction that two competitors i and j become the winners in depth k − 1 of the subtree under consideration. Then both the f lag value for i and the f lag value for j are set to 1 before executing waitfor in process i and waitfor in process j, respectively. Hence, both turn(comp(i, k)) = role(i, k − 1) and turn(comp(i, k − 1)) = role(j, k − 1) should hold true. However, this is also impossible. Hence, the statement for k − 1 holds true. ✷ Theorem 4: In tournamentPME on T (n, r), n = 2r (a + 1), the time from when a process i in the set of leaves of Gt has just entered the trying region until it enters the critical region is at most 2t+r+1 c + 11 × 2t+r+1 l. Proof: For k, 0 ≤ k ≤ d(i), define T (k) to be the maximum time from when a process i wins in depth k or it has just entered the trying region in depth k. Note that d(i) = t + r + 1 if t ≤ a − 1, and otherwise d(i) = t + r, where i is a leaf of Gt . Then T (d(i)) is the maximum time from when process i enters the trying region until it enters the critical region. It is immediate that T (0) ≤ l. Consider a situation that process i has just entered the competition in depth k of T (n, r). Let this event be denoted by π(i, k). By a similar analysis

IEICE TRANS. INF. & SYST., VOL.E82–D, NO.2 FEBRUARY 1999

374

to that in the proof of Theorem 2, within at most time 4l+T (k)+c+(k+2)l after π(i, k), f lag(opposite(i, k)) = 0 or turn(comp(i, k)) = role(i, k) is satisfied. Then within at most further time 2l, process i becomes a winner in depth k. Hence, the total time from π(i, k) until process i reaches the entrance to the critical region is at most 2T (k) + c + (k + 8)l. Thus we need to solve the following recurrence for T (d(i)). T (0) ≤ l T (k + 1) ≤ 2T (k) + c + (k + 8)l Thus, we can derive the following inequality. T (k) ≤ (c + 8l)(1 + 2 + 22 + · · · + 2k−1 ) + 2k l +(k + 2(k − 1) + 22 (k − 2) + · · · + 2k−1 )l ≤ 2k c + (2k+3 + 2k + 2k+1 )l = 2k c + 11 × 2k l Then T (d(i)) ≤ 2t+r+1 c + 11 × 2t+r+1 l if t ≤ a − 1, and T (d(i)) ≤ 2t+r c + 11 × 2t+r l if t = a. ✷ From Theorem 4, if u < v then the processes of Gu have an advantage of access to the resource over the processes of Gv . However, this does not mean that a process of Gu in the trying region always reaches the critical region earlier than any process of Gv in the trying region. Since the model to be asynchronous, a process may catch up a process at a higher level during the competition. For simplicity, in Theorem 4 we consider only the case where n = 2r (a + 1). Even in the case where the size of Ga is greater than other groups, the bound on the time from the trying region to the critical region is not more than twice the bound in Theorem 4. From Assertion 2 and Theorem 4 we have the next theorem. Theorem 5: tournamentPME solves the mutual exclusion problem and is lockout-free. 5.

Concluding Remarks

We have shown the speedup of the tournament algorithm for the asynchronous multi-writer/reader shared memory model. All variables turn(x) and f lag(x) used in n-tournamentFME assume only two values 0 and 1, whereas shared variables f lag(x) used in n-tournamentME assume log n + 1 different values. Hence, the total size of the shared variables of ntournamentFME is smaller than the total size of the shared variables of n-tournamentME although the former needs twice as many f lag variables as f lag variables of the latter. We are interested in the problem whether a further reduction of the total size of shared variables of the tournament algorithm is possible. There may be a natural request to design a distributed operating system such that some processes have an advantage of access to the resource over other

processes. Procedure tournamentPME was designed for this purpose. The mutual exclusion algorithms given in this paper do not guarantee the FIFO property. For tournamentPME, even if a process in a high priority group enters the trying region earlier than a process in a low priority group, the process in the low priority group may enter the critical region earlier than the process in the high priority group. We may be requested to design a mutual exclusion algorithm that guarantees an advantage of access to the resource in a stronger sense. These problems would be worthy for further investigation. References [1] J.E. Burns, “Mutual exclusion with linear waiting using binary shared variables,” ACM SIGACT News, vol.10, pp.42– 47, 1978. [2] J.E. Burns, P. Jackson, N.A. Lynch, M.J. Fischer, and G.L. Peterson, “Data requirements for implementation of N -process mutual exclusion using a single shared variable,” J. ACM, vol.29, pp.183–205, 1982. [3] J.E. Burns and N.A. Lynch, “Bounds on shared memory for mutual exclusion,” Information and Computation, vol.107, pp.171–184, 1993. [4] M. Choy and A.K. Singh, “Adaptive solutions to the mutual exclusion problem,” 12th Annual ACM Symposium on Principle of Distributed Computing, Ithaca, New York, pp.183–194, 1993. [5] A.B. Cremers and T.N. Hibbard, “Mutual exclusion of N processors using an O(N)-valued message variable,” 5th International Colloquium on Automata, Languages and Programming, Udine Italy, Lecture Notes in Computer Science, vol.62, pp.165–176, 1978. [6] E.W. Dijkstra, “Solution of a problem in concurrent programming control,” Commun. ACM, vol.8, p.569, 1965. [7] M.J. Fischer, N.A. Lynch, J.E. Burns, and A. Borodin, “Resource allocation with immunity to limited process failure,” 20th Annual Symposium on Foundations of Computer Science, San Juan, Puerto Rico, pp.234–254, 1979. [8] M.J. Fischer, N.A. Lynch, J.E. Burns, and A. Borodin, “Distributed FIFO allocation of identical resources using small shared space,” ACM Trans. Prog. Lang. and Syst., vol.11, pp.90–114, 1989. [9] L. Lamport, “The mutual exclusion problem. Part II: Statement and solutions,” J. ACM, vol.33, pp.327–348, 1986. [10] L. Lamport, “A new solution of Dijkstra’s concurrent programming problem,” Commun. ACM, vol.17, pp.453–455, 1974. [11] L. Lamport, “A fast mutual exclusion algorithm,” ACM Trans. Computer Syst., vol.5, pp.1–11, 1987. [12] N.A. Lynch, “Distributed Algorithms,” Morgan Kaufmann, San Francisco, California, 1996. [13] N.A. Lynch and M.J. Fischer, “On describing the behavior and implementation of distributed systems,” Theoretical Computer Science, vol.13, pp.17–43, 1981. [14] M. Merritt and G. Taubenfeld, “Speeding Lamport’s fast mutual exclusion algorithm,” Infor. Process. Lett., vol.45, pp.137–142, 1993. [15] G.L. Peterson, “Myths about the mutual exclusion problem,” Infor. Process. Lett., vol.12, pp.115–116, 1981. [16] G.L. Peterson and M.J. Fischer, “Economical solutions for the critical section problem in a distributed system,” Proc. 9th Annual ACM Symposium on Theory of Computing, Boulder, Colorado, pp.91–97, 1977.

IGARASHI et al: SOME MODIFICATIONS OF THE TOURNAMENT ALGORITHM FOR THE MUTUAL EXCLUSION PROBLEM

375

[17] E. Styer, “Improving fast mutual exclusion,” 11th Annual ACM Symposium on Principle of Distributed Computing, Vancouver, British Columbia, Canada, pp.159–168, 1992.

Yoshihide Igarashi received the B.Sc. degree in Electrical Engineering in 1962, and the M.Sc. and Ph.D. degrees in Electrical Communication Engineering in 1968 and 1971, respectively from Tohoku University. He was a Research Associate at Tohoku University during 1971– 1974, a Visiting Fellow at University of Edinburgh during 1972–1974, a Lecturer at University of Leeds during 1974–1977, and a Lecturer at City University during 1977–1978. In 1978 he joined Gunma University where he is currently a Professor in Computer Science. He was a Visiting Associate Professor and Visiting Professor at University of Kentucky during 1980–1981 and during 1987–1988, respectively. His research interests include the design and analysis of computer algorithms, parallel and distributed algorithms, and information security. Dr. Igarashi is a member of Association for Computing Machinery, IEEE Computer Society and Information Processing Society of Japan.

Hironobu Kurumazaki was born in Tatebayashi, Gunma Prefecture, Japan on January 30, 1975. He received the B.Eng. degree in Computer Science from Gunma University in 1997. He is pursuing the M.Eng degree in Computer Science at Gunma University. His current research interests include distributed algorithms, network protocols, and fault tolerant systems.

Yasuaki Nishitani received the B.E. degree in electrical engineering, the M.E. and the D.E. degrees in computer science from Tohoku University, Sendai, Japan, in 1975, 1977, and 1984, respectively. In 1981 he joined the Software Product Engineering Laboratory, NEC corporation. Since 1987 he has been an Associate Professor of the Department of Computer Science, Gunma University. His current research interests include the software engineering and distributed algorithms.

Suggest Documents