Prerequisite: Mutual exclusion in distributed systems
Ricart–Agrawala algorithm is an algorithm to for mutual exclusion in a distributed system proposed by Glenn Ricart and Ashok Agrawala. This algorithm is an extension and optimization of Lamport’s Distributed Mutual Exclusion Algorithm. Like Lamport’s Algorithm, it also follows permission based approach to ensure mutual exclusion.
In this algorithm:
- Two type of messages ( REQUEST and REPLY) are used and communication channels are assumed to follow FIFO order.
- A site send a REQUEST message to all other site to get their permission to enter critical section.
- A site send a REPLY message to other site to give its permission to enter the critical section.
- A timestamp is given to each critical section request using Lamport’s logical clock.
- Timestamp is used to determine priority of critical section requests. Smaller timestamp gets high priority over larger timestamp. The execution of critical section request is always in the order of their timestamp.
- To enter Critical section:
- When a site Si wants to enter the critical section, it send a timestamped REQUEST message to all other sites.
- When a site Sj receives a REQUEST message from site Si, It sends a REPLY message to site Si if and only if
- Site Sj is neither requesting nor currently executing the critical section.
- In case Site Sj is requesting, the timestamp of Site Si‘s request is smaller than its own request.
Otherwise the request is deferred by site Sj.
- To execute the critical section:
- Site Si enters the critical section if it has received the REPLY message from all other sites.
- To release the critical section:
- Upon exiting site Si sends REPLY message to all the deferred requests.
Ricart–Agrawala algorithm requires invocation of 2(N – 1) messages per critical section execution. These 2(N – 1) messages involves
- (N – 1) request messages
- (N – 1) reply messages
Drawbacks of Ricart–Agrawala algorithm:
- Unreliable approach: failure of any one of node in the system can halt the progress of the system. In this situation, the process will starve forever.
The problem of failure of node can be solved by detecting failure after some timeout.
- Synchronization delay is equal to maximum message transmission time
- It requires 2(N – 1) messages per Critical section execution
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Maekawa’s Algorithm for Mutual Exclusion in Distributed System
- Lamport's Algorithm for Mutual Exclusion in Distributed System
- Suzuki–Kasami Algorithm for Mutual Exclusion in Distributed System
- Mutual exclusion in distributed system
- Peterson's Algorithm for Mutual Exclusion | Set 2 (CPU Cycles and Memory Fence)
- Peterson's Algorithm for Mutual Exclusion | Set 1 (Basic C implementation)
- Mutual Exclusion in Synchronization
- Difference between Local File System (LFS) and Distributed File System (DFS)
- Algorithm for implementing Distributed Shared Memory
- Chandy-Misra-Haas's Distributed Deadlock Detection Algorithm
- Hierarchical Deadlock Detection in Distributed System
- Difference between Token based and Non-Token based Algorithms in Distributed System
- Limitation of Distributed System
- Features of Distributed Operating System
- Various Failures in Distributed System
- Logical Clock in Distributed System
- Hashing in Distributed Systems
- Deadlock detection in Distributed systems
- Deadlock Detection in Distributed Systems
- Advantages of Distributed database
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.