Maekawa's Algorithm for Mutual Exclusion in Distributed System


Multiple processes may require concurrent access to common resources in a distributed system. Concurrent access to a shared resource, however, may result in mistakes and inconsistencies. A distributed mutual exclusion algorithm must be employed to manage access to shared resources in order to guarantee mutual exclusion.

A distributed mutual exclusion technique, such as Maekawa's algorithm, ensures mutual exclusion between running processes in a distributed system. Only one process at a time can access a shared resource thanks to the algorithm, which is based on a voting system.

Maekawa's algorithm

A distributed mutual exclusion algorithm, such as Maekawa's algorithm, makes sure that concurrent processes in a distributed system exclude one another. The voting-based algorithm was proposed in 1985 by Mamoru Maekawa and Toshimitsu Masuzawa.

The algorithm divides the total number of processes in a distributed system into quorums or pairs of mutually intersecting subsets. Each process has a specific quorum allocated to it, and it can only allow access to the shared resource if it has gotten consent from every other process in its quorum as well as from every other process it has already received consent from.

A procedure can only grant permission if it is not already in its crucial portion in order to ensure mutual exclusion. Additionally, a process can only ask another process for permission if that other process isn't right now in its vital portion.

The technique ensures that a process will finally be able to access the shared resource since it ensures that at least one process from each quorum will eventually grant permission.

The mutual exclusion method developed by Maekawa is scalable, decentralized, and appropriate for massively distributed systems. The algorithm's performance, however, may be impacted by the need for several messages to be sent back and forth between processes.

The voting ring structure in Maekawa's algorithm

One of the most important elements of Maekawa's algorithm is the voting ring structure. This program creates a logical voting ring out of the processes in a distributed system. According to their allocated unique identities, each process is placed in a circular arrangement within the voting ring.

Which processes are permitted to grant authorization to use the shared resource is determined by the voting ring structure. The quorum for each procedure is determined by where it is in the voting ring. The process itself and a smaller subset of the other processes in the voting ring make up the quorum.

Each quorum's size is determined with care to ensure that it intersects with the others. Because it ensures that each process can request approval from at least one process in each quorum, the intersection property is significant.

A process must first wait for approval from all processes in its quorum before deciding which processes can provide permission. It can only issue permits to other processes in its quorum and to all processes that have asked for it once it has obtained consent from all processes in its quorum.

Pseudo code for Maekawaís Algorithm for Mutual Exclusion in Distributed System

A sample of Maekawa's algorithm for collective rejection in distributed systems is handed below

  • Each process has a unique ID and is assigned to a quorum based on its position in the voting ring.

  • Each quorum is a subset of processes in the voting ring, and quorums must intersect with each other.

  • A process can only grant access if it has received permission from all processes in its quorum as well as all processes it has received permission from.

  • To enter its critical section, a process must request permission from all processes in its quorum.

  • A process can only request permission from a process that is not currently in its critical section.

  • If a process is in its critical section, it leaves the voting ring temporarily to prevent other processes from requesting permission from it.

  • A process can grant permission to access the shared resource if it has received permission from all processes in its quorum.

  • If a process receives a request from another process that is not in its quorum, it forwards the request to a process in its quorum that has not already granted permission.

  • If a process receives permission from all processes in its quorum, it grants permission to the requesting process.

  • If a process leaves its critical section, it sends a message to all processes that have requested permission, informing them that permission has been granted.

  • If a process receives a permission message while waiting for permission, it adds the process to its list of processes that have granted permission.

  • If a process receives permission from all processes in its quorum and all processes it has requested permission from, it enters its critical section.

Comparison of Maekawa's algorithm with other mutual exclusion algorithms in distributed systems

The mutual exclusion voting algorithm developed by Maekawa is intended to be effective and fault-tolerant in distributed systems. Due to the usage of quorums, Maekawa's algorithm has a lower message complexity than other mutual exclusion algorithms like Ricart-Agrawala and Lamport's algorithm and requires fewer messages to provide access to the shared resource. Maekawa's technique is appropriate for usage in large-scale distributed systems because it can effectively tolerate node failures and network splits. However, because quorum sizes must be carefully chosen and quorum intersection must be guaranteed, Maekawa's technique has a greater setup overhead and is trickier to put into use.

Conclusion

A well-known mutual exclusion technique, Maekawa's algorithm offers a reliable and effective solution for distributed systems. Maekawa's algorithm minimizes the number of messages necessary for giving access to the shared resource by utilizing a voting-based technique with quorums. Lower latency and higher performance follow from this. Maekawa's technique is appropriate for large-scale distributed systems because it can manage node failures and network partitions. However, because quorum sizes must be carefully chosen and quorum intersection must be guaranteed, Maekawa's technique has a greater setup complexity and may be more difficult to use in actual applications. Despite this, due to its effectiveness and fault tolerance, Maekawa's method is still a preferred option for mutual exclusion in distributed systems.

Updated on: 04-May-2023

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements