Mutual Exclusion in Distributed Computing

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

Process

Synchronization
Types of Process:
– Independent Process 
– Cooperative Process 
Process synchronization problem arises in the case of
Cooperative process like
– Race Condition
– Critical Section Problem
Any solution to the critical section problem must satisfy three
requirements:
Mutual Exclusion, Bounded Wait, Progress

1
What is Mutual

Exclusion?
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.
• It must not be possible for a process requiring access to a critical
section to be delayed indefinitely: No deadlock or starvation

2
Requirements of Mutual
exclusion Algorithm:
• No Deadlock
Two or more site should not endlessly wait for any message
• No Starvation
Every site who wants to execute critical section should get an
opportunity to execute it in finite time.
• Fairness
Each site should get a fair chance to execute critical section
• Fault Tolerance
In case of failure, it should be able to recognize it by itself in order to
continue functioning without any disruption.

3
How to tackle mutual
exclusion in Distributed

systems?
In single computer system, memory and other resources are
shared between different processes. Using Semaphores and
shared variables we can solve the problem of Mutual
Exclusion.
• Whereas in Distributed systems, we neither have shared
memory nor a common physical clock. So to eliminate the ME
problem, approach based on message passing is used.
• Different approaches used for this are:
Centralized Approach
Token Based Algorithm
Non-token based approach

4
Centralized algorithm
• Mimic single processor system
• One process elected as coordinator
request(R)
C
1. Request resource
2. Wait for response grant(R)
3. Receive grant P
4. access resource release(R)
5. Release resource
Centralized algorithm
If another process claimed resource:
– Coordinator does not reply until
release
– Maintain queue
• Service requests in FIFO order

Queue request(R)
P2
P1 request(R)
C
P2 request(R)
grant(R)
P0
release(R) P1
Advantages
• It is easy to understand, implement and verify.
• Mutual Exclusion is achieved as the coordinator
lets only one process at a time into the critical
section.
• No process waits forever hence no starvation.
• Fair
– All requests processed and granted in the
order in which they are received.
Disadvantages
• The coordinator is a single point of failure, so if it
crashes the entire system may go down.
• If process is blocked after making a request, they
cannot distinguish a dead coordinator from
“access denied” since in both cases coordinator
doesn’t reply.
• In a large system, a single coordinator has to take
care of all processes which can lead to a
bottleneck.
Ricart & Agrawala algorithm
• Distributed algorithm
• Process wants to enter critical section:
– Compose message containing:
• Identifier (machine ID, process ID)
• Name of resource
• Timestamp (totally-ordered Lamport)
– Send request to all processes in group
– Wait until everyone gives permission
– Enter critical section / use resource

9
Ricart & Agrawala algorithm
• When process receives request:
– If receiver not interested:
• Send OK to sender
– If receiver is in critical section
• Do not reply; add request to queue
– If receiver just sent a request as well:
• Compare timestamps: received & sent messages
• Earliest wins
• If receiver is loser, send OK
• If receiver is winner, do not reply, queue
• When done with critical section
– Send OK to all queued requests
10
Working Example

Not Intrested
Not Intrested

11
Advantages
• Mutual exclusion can be achieved without
deadlock or starvation.
• The number of messages required per entry
into CS is 2(n-1), where the total number of
process in the system is n.
• All processes are involved in all decisions.

12
Disadvantages
• Unfortunately, the single point of failure has been
replaced by n points of failure.
• If any process crashes, it will fail to respond to
requests.
• This silence will be interpreted incorrectly as denial of
permission.
• Each process must maintain the group membership list
itself, including processes entering the group, leaving
the group and crashing.

13
Conclusion

Algorithm Messages per entry/exit Problems

Centralized 3 Coordinator Crash

Ricart & Agrawala 2(n-1) Crash of any process

Lamport 3(n-1) Crash of any process

Token Ring 1 to ∞ Lost token, process crash

14
Thank you

15

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy