Open In App

Mutual exclusion in distributed system

Mutual exclusion is a concurrency control property which is introduced to prevent race conditions. It is the requirement that a process can not enter its critical section while another concurrent process is currently present or executing in its critical section i.e only one process is allowed to execute the critical section at any given instance of time. 

Mutual exclusion in single computer system Vs. distributed system: In single computer system, memory and other resources are shared between different processes. The status of shared resources and the status of users is easily available in the shared memory so with the help of shared variable (For example: Semaphores) mutual exclusion problem can be easily solved. In Distributed systems, we neither have shared memory nor a common physical clock and therefore we can not solve mutual exclusion problem using shared variables. To eliminate the mutual exclusion problem in distributed system approach based on message passing is used. A site in distributed system do not have complete information of state of the system due to lack of shared memory and a common physical clock. 



Requirements of Mutual exclusion Algorithm:

Some points are need to be taken in consideration to understand mutual exclusion fully :



1) It is an issue/problem which frequently arises when concurrent access to shared resources by several sites is involved. For example, directory management where updates and reads to a directory must be done atomically to ensure correctness.
2) It is a fundamental issue in the design of distributed systems.
3) Mutual exclusion for a single computer is not applicable for the shared resources since it involves resource distribution, transmission delays, and lack of global information.
 

Solution to distributed mutual exclusion: As we know shared variables or a local kernel can not be used to implement mutual exclusion in distributed systems. Message passing is a way to implement mutual exclusion. Below are the three approaches based on message passing to implement mutual exclusion in distributed systems:

1. Token Based Algorithm:

Example : Suzuki–Kasami Algorithm

2. Non-token based approach:

Example : Ricart–Agrawala Algorithm

3. Quorum based approach:

Example : Maekawa’s Algorithm

FAQs:

How does the token-based algorithm handle the failure of a site that possesses the token?
If a site that possesses the token fails, then the token is lost until the site recovers or another site generates a new token. In the meantime, no site can enter the critical section.

What is a quorum in the quorum-based approach, and how is it determined?
A quorum is a subset of sites that a site requests permission from to enter the critical section. The quorum is determined based on the size and number of overlapping subsets among the sites.

How does the non-token-based approach ensure fairness among the sites?
The non-token-based approach uses a logical clock to order requests for the critical section. Each site maintains its own logical clock, which gets updated with each message it sends or receives. This ensures that requests are executed in the order they arrive in the system, and that no site is unfairly prioritized.

Article Tags :