0% found this document useful (0 votes)
193 views13 pages

Ricart Agrawala Algorithm in Mutual Exclusion Distributed Systems

Uploaded by

Ravi Prakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
193 views13 pages

Ricart Agrawala Algorithm in Mutual Exclusion Distributed Systems

Uploaded by

Ravi Prakash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Ricart–Agrawala

Algorithm in Mutual
Exclusion
Distributed Systems

Arunkumar R.
AP/CSE.
preencoded.png
Introduction to Mutual Exclusion in Distributed
Systems
1 What is Mutual Exclusion? 2 Need for Mutual Exclusion

A condition in distributed systems where only To avoid conflicts in accessing shared resources
one process is allowed to execute a critical and maintain consistency in distributed
section at a time to prevent race conditions. computing.

preencoded.png
Challenges in Achieving
Mutual Exclusion
Absence of Global Clock
No global time reference in distributed systems.

Decentralized Nature
No central controller to manage resource access.

Message Passing
All communication happens via message passing between
processes.

preencoded.png
Overview of Ricart–Agrawala Algorithm

Introduction Type of Algorithm Developed By

The Ricart–Agrawala algorithm is Non-token-based distributed Glenn Ricart and Ashok Agrawala
a message-passing protocol for mutual exclusion algorithm. in 1981.
achieving mutual exclusion in
distributed systems.

preencoded.png
Assumptions in the Algorithm
System Assumptions

Fully connected network where processes can directly communicate with


each other. Communication between processes is reliable and happens
through message passing.

Process Assumptions

Each process has a unique identifier. Processes are asynchronous but follow
a logical sequence of events.

preencoded.png
Ricart–Agrawala Algorithm
1. Requesting the Critical Section:
o When process Pi​ wants to enter the critical section (CS):
▪ It increments its logical clock.
▪ Sends a REQUEST message to all other processes Pj​, containing its timestamp and process ID.
▪ Adds its own request to the request queue.
2. Receiving a Request Message:
o When a process Pj receives a REQUEST (ti, i) from process Pi:
▪ If Pj is not in the critical section and has not requested access to the CS, or if Pj's request timestamp is higher than P i's:
▪ Send an OK message to Pi​.
▪ Else:
▪ Delay the reply until after it exits the CS or has a lower timestamp.
3. Entering the Critical Section:
o Process Pi​ enters the CS when it receives OK messages from all other processes.
4. Releasing the Critical Section:
o After exiting the CS, Pi​:
▪ Sends a RELEASE message to all other processes.
▪ Removes its own request from the request queue.
5. Handling Release:
o When a process Pj​ receives a RELEASE message: preencoded.png

▪ It removes the request from its queue and processes the next request (if any).
Algorithm Workflow
1 Requesting the Critical Section
A process sends a REQUEST message to all other processes. The
REQUEST contains the process's unique ID and timestamp (Lamport
clock).
2 Receiving Requests
Each process maintains a queue of requests ordered by timestamp.
Upon receiving a REQUEST message, the process can either reply with
an OK message if it's not in the critical section or has a later request, or
delay the reply if it's in the critical section or has an earlier request.

3 Entering the Critical Section


A process enters the critical section only after receiving OK messages
from all other processes.

4 Releasing the Critical Section

After exiting the critical section, the process sends a RELEASE message
to all processes. Processes update their request queues accordingly.
preencoded.png
preencoded.png
preencoded.png
preencoded.png
preencoded.png
Key Features of the Ricart–
Agrawala Algorithm
1 Message Complexity
2(N - 1) messages are required for mutual exclusion (N is
the number of processes).

2 Fairness
Ensures that requests are granted in the order of their
timestamps, preventing starvation.

3 Deadlock-Free
No circular wait, as requests are processed in a logical order.
preencoded.png
Benefits of Ricart–Agrawala
Algorithm
No Token Dependency
Unlike token-based algorithms, there is no single point of failure.

Scalability
Works well in large distributed systems.

Logical Time Stamping


Utilizes Lamport's logical clock to ensure requests are
processed in the correct order.

preencoded.png

You might also like