Using Maekawa’s Algorithm to Perform Distributed Mutual Exclusion in Quorums

In distributedsystems,cooperatingprocessesshareboth local and remotersources. Chance isveryhighthatmulti-pleprocessesmakesimultaneous requests to the same resource. If the resourcerequires mutually exclusive access (critical section - CS), thensomeregulation isneeded to access it for ensuring synchronizedaccess of the resources thatonly one process could use the resource at a given time. This is the distributed mutual exclusion problem. The problem of coordinating the execution of critical sections by eachprocessissolved by providing mutually exclusive access to the CS. Mutual exclusion ensures that concurrent processes make a serialized access to shared resources.Quorum-based algorithms offer the advantage of protocol symmetry, spreading effort and responsibility uniformly across the distributed systems. In thispaper, we have proposed a permission baseddistributedmutual exclusion algorithmwhichis an improvement of Maekawa’s algorithm. The number of messages required by the improvisedalgorithmis in the range 3Mto 5Mper critical section invocation whereMis the number of intersection nodes 1 in the system. A reduction in number of message by restricting the communication of anynodewith the intersection nodes of the quorums, withoutany modification of the basic structure of the algorithm.


Introduction
Distributed mutual exclusion problem arise when concurrent access to protected resource (termed as Critical Section (CS)) by several sites is involved. In d istributed mutual exclusion, the requirement is to serialize the access to CS in the absence of shared memory, wh ich further co mplicates the problem.
Mutual exclusion (MUTEX) is a fundamental problem in distributed systems, where a g roup of hosts intermittently require entering the Critical Section in o rder to exclusively perform some critical operations, e.g. accessing the shared resource. A solution to the MUTEX problem must satisfy the following three correctness properties: • Mutual Exclusion (safety): At most one host can be in the CS at any time; • Deadlock Free (liveness): If any host is waiting for the CS, then in a fin ite time some host enters the CS; • Starvation Free (fairness): If a host is waiting fo r the CS, then in a fin ite time the host enters the CS.
Many MUTEX algorith ms have been proposed for traditional distributed systems [2] wh ich can be categorized into two classes: tok en-based algorithms and permission-based algorith m. In token-based algorith ms, a token is passed among all the hosts. A host is allowed to enter the CS only if it possesses the token. In a permission-based algorithms, the host requesting for the CS must first obtain the permissions fro m other hosts by exchanging messages.
Distributed mutual exclusion algorithms can be classified as token-based and non-token-based as suggested by [2], or as token-based and permission-based as suggested by [3]. In this paper, we proposed a permission based distributed mutual exclusion algorithm, wh ich is an improvement of Maekawa's algorith m [1].
In Suzuki-Kasami's broadcast [14], when a node wants to enter the crit ical section, it broadcasts a message to all other nodes. Whoever holds the token sends the token directly to the node tat wants to enter the CS. The algorith m requires N messages for handling each request. The simp lest of token-based algorith ms is the Agrawal-Elabbaei's token ring approach [13]. In this algorith m, the nodes in the system form a logical ring. A token always passes around the ring clockwise or anticlockwise. A node can enter the critical section if it holds the token. On an average N/2 messages are required to handle one request in an N nodes system. Niealsen and Mizuno extended by passing the token directly to the requesting node instead of through intermediate node [15]. Naimi-Trehel's algorith m [16] maintains a dynamic logical tree, such that the root of the tree is always the last node that will get the token among the current requesting ones. Chang, Singhal and Liu [17] imp roved this algorith m, aimed to reduce the number of messages to find the last requesting host in the logical tree. Mueller [18] also proposed an extension to Naimi-Trehel's algorith m, introducing the concept of priority and the algorithm satisfies the request with higher priority.
Garcia-Molina and Barbara [4] first introduced the concept of coterie which could be mainly used to devise permission based distributed mutual exclusion algorithms. A coterie consists of collection of sets of sites in the system and these sets are called quorums. In general, when a node wants to execute its CS, it has to obtain permission from processes of any quorum in the coterie. Maekawa's algorith m [1] was the first coterie-based algorith m where the nodes of the system are logically arranged into groups. Any node intending to execute its CS has to obtain permission fro m all the nodes in its respective group and these groups were created such that any two groups had at least one node in co mmon (referred to as intersection nodes) which act as arbitrators. In this paper, we further restrict the co mmunication of the processes, which want to execute its CS to their intersection nodes and achieve distributed mutual exclusion in lesser number of messages.
Maekawa's algorithm [1] uses cK messages to create mutual exclusion in the distributed system, whereas our proposed algorithm takes cM (M<K) messages per CS invocation where M, K and c are integers and 3 ≤ c ≤ 5. However, our proposed algorith m preserves all the advantages of Maekawa's algorith m [1] and remains similar to it. The algorith m p roposed in this paper is not fair, the synchronization delay is 2 and the algorithm is starvation-free.
The problem of resolving conflicting access to resources also arise in replicated databases, where the emphasis is on resolving read and write conflicts efficiently. Many methods [5][6][7][8]10,12] have been used to address this issue. Document structure: The rest of the paper is organized as follows. Section 2. is designated for related work. Section 3. Talk about our distributed system model. Section4. reviews Maekawa's algorith m [1]. In section5, we present our proposed algorithm. Section6. presents the proof of correctness. In section 6, we present the analysis of the proposed algorithm. Finally, we conclude in section 8.

Related Work
Quorum systems are used to solve many coordination problems in distributed systems such as mutual exclusion, data replicat ion, distributed consensus, and commits protocols.
A quorum system is a collection of sets quorums, wh ich mutually intersect. A replicated database is a distributed database in which mu ltip le copies of some data items are stored at mu ltiple servers. One of the advantages of data replicat ion is to increase data availability so that the system can remain operational even though some servers have failed. Another advantage of data replication is to improve per-formance. With many copies of each data item being available, a user transaction is more likely to find the data is needed nearby. However, these benefits are offset by the cost of maintain ing data consistency.
The load of a quorum system measures the share that processors have handling request to quorum. Given a probability distribution on quorum accesses, the load of an element is equal to the sum of the access probability of all quorums it belong to. Fo r a given probability distribution, the quorum system load is the maximu m of the load of all elements. The load of a quorum system is the min imu m over all access probability distributions. The availab ility of a quorum system measures the probability that the system is usable when failu res occur. A quorum system is availab le given that processors fail accord ing to some probability distribution. The failure probability of a quorum system is the probability that the quorum is not available. The cost failu re is used to measure the overhead message complexity due to failures. If a quorum set has some faulty servers, then it is not usable because it is not guaranteed to share a correct server with every other quorum. In th is case, a server attempting to access the quorum with failed servers must find another quorum with no failed servers. Informally, the cost of failures is the additional nu mber of servers that need to be contacted when failure occurs.
Ku mar introduced quorum system based on a hierarch ical construction Maekawa showed that for a fixed integer k, the maximu m possible value of N in which all the properties can be satisfied is equal to k(k+1)+1, where k is a power prime, by assuming that any two quorums have only one intersection. Hence, the theoretical lower bound of the quorum is approximately equal to √N. Furthermo re, he also mentioned that finding the possible solution for N=k(k+1)+1 is equivalent to find a finite project ive plane of order k. Nevertheless, not all finite projective planes exist and we only know how to construct those with power order k=p i where p is a prime nu mber and i an integer.
For the others values of k, one way to create the sets is relaxing some of the conditions imposed on the quorums, or by creating sets for a larger N and the discarding some sets. In theory, we can solve the optimal quorum problem by generating all the comb inations and see which one satisfies all properties. However, the time co mplexity of this exhaustive search algorith m is exponential.
To solve this problem, several methods have been proposed to generate the near-optimal solution.

Distributed System Model
The distributed system consists of n distinct servers, which co mmunicate with each other by message passing over connected network. The messages take finite but arbitrary time to reach at the receiv ing servers. In this paper, we share in their design to fo llo wing assumptions and conditions for the distributed system environ ment. All processes in the distributed system are assigned unique identification numbers.

Notion of Quorum
Definition 3.1:A finite pro jective plane is a collect ion of k 2 +k +1 points and k 2 +k +1 lines such that the following fours axio ms hold: (ⅰ ) Every line contains k +1 points.  (ⅳ) Equal effort: every server i appears in (k+1) S j The subsets S i s are called quorum. Quorum that satisfy the minimality, the mutual intersection and non-emptiness properties fro m a coterie. The equal size and equal effort properties define the additional notion of symmetry in the coterie. Equal size quoru m ensures that each server or client sends the same number of message to request the shared resource. The equal effort property requires that each server be included in the same nu mber o f quoru ms, ensuring that all sites expend the same effort in enforcing distributed mutual exclusion.
The selection of S i s is not unique. There exists a number of ways to select a set S i that satisfies the above properties. The problem of finding a set of Q is that satisfies these conditions are equivalent to finding a finite projective plane of N points. It is known that there exists a finite pro jective plane of order k if k is a power of a prime nu mber p. This fin ite projective p lane has (k+1) lines and k points per line.

Maekawa's Algorithm
In this section, we present the computational model for the proposed algorithm and a review of Maekawa's algorith m.

The Computational Model
In this paper, we assume that a distributed system, wh ich is common to Maekawa's algorithm and to the proposed algorith m, consists of N sites {1, 2, 3, …, j, …, N}. A distributed system is asynchronous, i.e., there is no common global clock. Informat ion exchanged between processes is done by asynchronous message passing. Each co mmunication channel is FIFO and each message sent is delivered within finite t ime, but there is no upper bound on message delivery time. We assume that the system is error free.
The different type of messages used is REQUEST, LOCKED, IN QUIRY, FAILED, RELINQUISH and RE-LEASE. Timestamps (TS) at any site i (where 1≤ i ≤ N), TS i are ordered by (L i , i), containing the Lampo rt's logical clock [10] value L i and the site id i.
An ordering, "<" on timestamps is defined as: TS i <TS j iff (L i <L j ) o r (L i =L j and i < j).

The Algorithm
In Maekawa's algorithm, a site does not request permission fro m all the sites, but only from a subset of sites. The sites of the system are div ided into groups called quorums (S i, ,1≤ i ≤ N). The quorums are constructed such as to satisfy the following conditions: (ⅰ) ∀i, ∀j, S i ∩ S j ≠∅, i ≠ j, 1≤i,j≤N (ⅱ) ∀i, node i ∈S j , 1≤ i ≤N (ⅲ) ∀i, S i =K, 1≤ i ≤ N (ⅳ) ∀j, node j is with in KS i s, 1≤i,j≤N Condition (i) (non null intersection property) is a necessary condition for the S i 's so that mutual exclusion requests can be resolved. Condition (ii) reduces the number of messages to be sent and received by a node. Condition (iii) means that each node needs to send and receive the same number of messages to obtain mutual exclusion (equal work). Finally condition (iv) signifies that each node is equally responsible for mutual exclusion (equal responsibility). For examp le, the finite projective plane of order 2 seen in Section 3. workswell in the case of Maekawa's algorith mwith the properties of quorums definedabove.
Maekawa establishes the following relationship between N and K: N=K(K-1)+1. Hence K can be found approximated to √N.
For any node i, who intends to execute its CS, the algorith m works as follows.
Entry section:Process i mu lticasts the REQUEST to all the nodes in its S i including itself. The intersection nodes can send the REQUEST messages to any one of the districts to which theybelong. When a process j receives the RE-QUES T message, it sends LOCKED message to site i if it has not yet sent it to any other site fro m the time it received RELEASE message. Or else it queues the REQUEST. CS executi on: Process i executes its CS after receiving LOCKED message from all the nodes of its S i . Exi t section: After executing its CS, site i sends RE-LEASE message to all nodes of its S i which restores node's right to send LOCKED message to any other pending requests in the queue.
This basic algorith m is prone to deadlock which is handled as follo w: Assume that a site j has LOCKED message to some site k and it later receives a REQUEST message fro m any other site i (i≠ k). Then, node j sends FAILED message to site i if TS k <TS i , otherwise it sends INQUIRY message to site k. When such a process k receives INQUIRY message, it sends RELINQUISH message to site j if site k has received FAILED message fro m at least one site in S k , and has not received new LOCKED message from it(after receipt of FAILED message).

The Proposed Algorithm
Our proposed algorith m presents an improvement to the Maekawa's distributed mutual exclusion algorith m. Fro m Maekawa's algorith m [1] it is clear that the role of the arbitrator is to resolve the conflicting requests to enter CS. Every node has the responsibility to beco me an arbit rator to handle the conflicting requests coming fro m the quorum to which it belongs. Nodes that belong to more than one quorum (referred to as intersection nodes), act as inter-quorum arbitrators, resolving conflict ing requests arising from nodes of different quoru ms. Because of the role played by these intra and inter-quoru m arb itrator, the mutual exclusion condition is maintained throughout the entire network.
Intersection nodes can also act as intra-quorum arb itrators since they are also the members of the quorum. Here we see that, since the intersection nodes can act as both inter-quorum and intra-quorum arb itrators, and since every quorum should have at least one intersection node, all conflicting requests can be resolved by communicating with intersection nodes of the system. This way, we can achieve per CS invocation with respect to Maekawa's algorith m [1], as all the messages required to commun icate with non-intersection nodes can be eliminated.
Hence our proposition is: Maekawa's d istributed mutual exclusion algorith m can perform better (in terms of number of messages required) by restricting the entire algorithm related co mmunication to be carried out with only the intersection node in the quorum.
In Maekawa's algorith m [1], all nodes in the quorum are intersection nodes (from condition (iv) for construction of quorums which is outlined in section 4.) and hence all nodes work as inter-quorum arbitrators. To ensure that number of nodes in the quorum, we propose to liberalize the conditions for construction of quorums in Maekawa's algorith m [1].
The quorums in our algorithm are constructed using the following conditions: (i) ∀i, ∀j, S i ∩ S j ≠∅, i ≠ j, 1≤i,j≤ y, where y is the number of quorums, y ≤ N (ii) Node i belongs to at least one of the quorums (iii) The number of nodes in the quorum needs to be equal.
Here, we presented the conditions in the same way as done by Maekawa's algorithm in the previous section so that the reader may note the difference. Condit ions (i) and (ii) are required to ensure correctness of the algorithm. In Maekawa's algorith m [1], it was required to have k number of nodes in the entire quoru m to ensure that all nodes perform an equal amount of work for each CS invocation, which is a desirable feature o f a truly d istributed system. The system using our algorith m would be a pseudo-distributed system as the non-intersection nodes do not participate in CS invocation of other nodes and hence condition (iii) follows.
The basic working of the algorith m and the required types of messages need not to be modified. Th is improvisation would shift the responsibility to maintain the mutual exclusion condition to the intersection nodes.

Mutual Excl usion
Mutual exclusion is achieved when no pair of processes is ever simultaneously in its crit ical section. For any pair of processes, one must leave its CS before the other may enter.
Theorem 6.1: The proposed algorithm ensures the mutual exclusion property.
Proof: By contradiction. Let us assume that, any two nodes i and j are executing the CS simu ltaneously. Let S i and S j be the quorums of i and j respectively. Let S i ' and S j ' be sets of intersection nodes of S i and S j respectively. Let k be a node that belongs to the intersection of S i and S j .
Consider the case when S i =S j (i.e. i and j belongs to the same quoru ms), then, we choose k fro m S i '. Since S i =S j , we have S i '=S j '. Thus k belong to S j ', hence k belongs to both S i ' and S j '. If S i ≠S j , since k belongs to both S i and S j , k is an intersection node, k belongs to both S i ' and S j '.
Since i is executing the CS, i has captured the LOCKED message fro m the entire node belonging to S i ' including k. Since j is also executing the CS, j also should have captured the LOCKED messages from all the nodes belonging to S j ' including k. Thus k has been locked by 2 requests simultaneously. However, according to the algorith m only one request can lock a node at a time. Thus maximu m of only one process can execute the CS at any time.
This proof holds well when i and j belong to same quorum as well as different quorums. Thus, we see that the proposed improvement does not affect the correctness of the algorith m.

Deadlock and Starvation
The system of nodes is said to be deadlocked when no process is in its CS and no requesting process can ever proceed to its CS.
Starvation occurs when one process must wait indefinitely to enter its CS even though other processes are entering and exit ing their own critical section. Theorem 6.2: The proposed algorithm is deadlock and starvation free.
Proof: Since no two requests carry same timestamp (priority), total ordering is achieved among requests. If the total ordering condition is followed strictly "circu lar wait" condition is not satisfied, and hence deadlock cannot occurs [11].
If an arbitrator (here an intersection node) finds out that it has actually violated the total ordering condition by sending LOCKED message to a request with higher priority when there is a request with lower priority waiting in the request queue, it sends an INQUIRY message to the recipient of the LOCKED message. Then if the recipient node has already started executing the CS, it will not reply. If the recipient node has not yet entered the CS and if it receives a FAILED message fro m at least one of the intersection process, then it would send the RELINQUIS H message to the arbitrator and release the lock on that node. Then the arbitrator can get locked to the request with lesser timestamp. Here the "No pre-emption" condition is not satisfied. Thus, in any case a deadlock situation cannot occur in the system.
Since no mod ification has been done to the way the timestamp of a node is used or updated, even the improvised algorith m is starvation free, similar to the original Maekawa's algorith m [1].

Performance Analysis
Let M be the number of intersection nodes in the quorum. In the best case where there is no relinquishment happening, we have M REQUEST messages being sent by the requesting node for every CS invocation. The node receives M LOCKED messages. After executing its CS, node sends M RELEASE messages. Thus 3M number of message is required. In the wo rst case, where every LOCKED message is relinquished, we have additional k number of IN QUIRY and RELIN QUISH messages each. Thus 5M (3M+2M) number of messages is required. Hence, the number of messages required for every CS execution after mod ification is cM, where 3≤ c≤5.
The value of M depends on the way the have the nodes have been distributed into various quorums. When M=1, then the system is similar to a centralized system. When M = N, for all the nodes, then the algorithms performs similar to that of Ricart-Agrawala's algorith m [12]. WhenM=√N, the algorithm performs similar to original Maekawa's algorith m. Also, it can be noted that, in any case, the number of intersection processes in a quorum is lesser than or equal to the number of messages required by the original algorith m. The system can be designated is such a way that M <√N for all the quorums of the system, in wh ich case the imp rovised algorith m would require lesser number of messages than the original Maekawa's algorith m.

Conclusions
In this paper, we have proposed a permission-based distributed mutual exclusion algorithm, wh ich is an improvement of Maekawa's algorith m. The proposed algorithm is a modification of Maekawa's distributed mutual exclusion algorith m and signification reduction in the number of messages is being achieved by restricting the communication of any node of the quoru ms. The proposed algorithm does not introduce any additional overheads over the existing Maekawa's algorith m, wh ich requires 3K to 5Knumbers of messages per CS invocation, where K is the number of nodes in the quorum (M < K ).