CS8603 - DS - Unit 3 - Session 1 To 3
CS8603 - DS - Unit 3 - Session 1 To 3
1 algorithm CO4 K2
1 Suzuki broadcast algorithm CO4 K2
Deadlock detection in distributed systems: Introduction System CO4
1 K2
model Preliminaries
1 Models of deadlocks CO4 K2
1 Algorithms for the single resource model CO4 K2
1 the AND model and CO4 K2
1 the OR model. CO4 K2
DR S. PALANIAPPAN, ASSOCIATE PROFESSOR CSE
Introduction
A mutual exclusive (mutex) is a program object that prevents simultaneous access to a
shared resource.
Only one process is allowed to execute the critical section (CS) at any given time.
Message passing is the sole means for implementing distributed mutual exclusion.
DR S. PALANIAPPAN, ASSOCIATE PROFESSOR CSE
Types of Mutual Exclusion
Distributed mutual exclusion algorithms must deal with unpredictable message delays
and incomplete knowledge of the system state.
This common site is responsible to make sure that only one request
executes the CS at any time.
Safety Property: At any instant, only one process can execute the critical section.
Liveness Property: This property states the absence of deadlock and starvation. Two or
more sites should not endlessly wait for messages which will never arrive.
Fairness: Each process gets a fair chance to execute the CS. Fairness property
generally means the CS execution requests are executed in the order of their arrival
(time is determined by a logical clock) in the system
Message complexity
number of messages that are required per CS execution by a site
Synchronization delay
After a site leaves the CS, it is the time required and before the next site enters
the CS
The time interval a request waits for its CS execution to be over after its
request messages have been sent out
System throughput: The rate at which the system executes requests for the CS.
system throughput=1/(SD+E)
We often study the performance of mutual exclusion algorithms under two special
Under low load conditions, there is rarely more than one request for the critical
section present in the system simultaneously.
Under heavy load conditions, there is always a pending request for critical section at
a site.
Requests for CS are executed in the increasing order of timestamps and time is
determined by logical clocks.
Every site Si keeps a queue, request queuei , which contains mutual exclusion
requests ordered by their timestamps.
This algorithm requires communication channels to deliver messages the FIFO order.
The Lamport algorithm works by passing three messages: REQUEST, REPLY, and
RELEASE
P1
P2
P3
P1
P2
P3
P1
P2
P3
P1
P2
P3
P1
P2
P3
When a site Si wants to enter the CS, it broadcasts a REQUEST(tsi , i ) message to all
other sites
DR S. PALANIAPPAN, ASSOCIATE PROFESSOR CSE
Requesting the critical section
P1
P2
P3
P1
P2
P3
When a site Sj receives the REQUEST(tsi , i ) message from site Si ,places site Si
request on request queuej and it returns a timestamped REPLY message to Si .
DR S. PALANIAPPAN, ASSOCIATE PROFESSOR CSE
Executing the critical section
Site Si enters the CS when the following two conditions hold:
P1
P2
P3
L1: Si has received a message with timestamp larger than (ts i , i ) from all other sites.
L2: Si i.
DR S. PALANIAPPAN, ASSOCIATE PROFESSOR CSE
Releasing the critical section
P1
P2
P3
Site Si, upon exiting the CS, removes its request from the top of its request queue and
broadcasts a timestamped RELEASE message to all other sites.
DR S. PALANIAPPAN, ASSOCIATE PROFESSOR CSE
Releasing the critical section
P1
P2
P3
Basic idea:
Processes that require entry to a CS multicast a request message
Processes can enter the CS only when all the other processes have replied to this
message
Node pj does not need to send a REPLY to node pi if pj has a request with timestamp
lower than the request of pi (since pi cannot enter before pj anyway in this case)
The Ricart-Agrawala algorithm assumes the communication channels are FIFO. The
algorithm uses two types of messages: REQUEST and REPLY.
Initially,
i j : RDi [j]=0.
Whenever pi defer the request sent by pj , it sets RDi [j]=1 and after it has sent a
REPLY message to pj , it sets RDi [j]=0.
P1
P2
P3
P1
P2
P3
When site Sj receives a REQUEST message from site Si , it sends a REPLY message
to site Si if site Sj is neither requesting nor executing the CS, or if the site Sj is
requesting and Si is smaller than site Sj
timestamp.
P1
P2
P3
P1
P2
P3
Site Si enters the CS after it has received a REPLY message from every site it sent a
REQUEST message to.
DR S. PALANIAPPAN, ASSOCIATE PROFESSOR CSE
Releasing the critical section
P1
P2
P3
When site Si exits the CS, it sends all the deferred REPLY messages: j if RDi [j]=1, then
send a REPLY message to Sj and set RDi [j]=0.
DR S. PALANIAPPAN, ASSOCIATE PROFESSOR CSE
Releasing the critical section
P1
P2
P3
Thus
A site does not request permission from all other sites, but only from a subset of the
sites.
A site can send out only one REPLY message at any time. A site can send a REPLY
message only after it has received a RELEASE message for the previous REPLY
message.
Equal size means that each node needs to send and receive
for all i: |Ri| = K, for some K the same number of messages to obtain mutual
exclusion (equal work).
If K = D = 3 then N = 7.
FAILED - indicates that Si cannot grant request because it has currently granted
permission to a site with a higher priority request.
INQUIRE - indicates that Si would like to find out from Sj if it has succeeded in
locking all the sites in its request set.
Uses sequence numbers rather than timestamps to differentiate between old and
current requests
A site Si keeps an array of integers RNi [1..N] largest seq number received so far
from site Sj.
After executing its CS, a site Si updates LN[i]:=RNi [i] to indicate that its request
corresponding to sequence number RNi [i] has been executed.