Module 3
Module 3
Module 3
Module - III
Module – III
Lesson Plan
L1: Distributed mutual exclusion algorithms – System model, Lamport’s algorithm
L2: Ricart–Agrawala algorithm
L3: Quorum-based mutual exclusion algorithms – Maekawa’s algorithm
L4: Token-based algorithm – Suzuki–Kasami’s broadcast algorithm.
L5: Deadlock detection in distributed systems – System model, Deadlock
handling strategies, Issues in deadlock detection.
L6: Models of deadlocks
Distributed mutual exclusion algorithms
Mutual exclusion is a fundamental problem in distributed computing systems.
1. Token-based approach.
2. Non-token-based approach
3. .Quorum-based approach.
Distributed mutual exclusion algorithms
In the token-based approach, a unique token is shared among the sites.
A site is allowed to enter its CS if it possesses the token and it continues to hold the
token until the execution of the CS is over.
A site enters the critical section (CS) when an assertion, defined on its local variables,
becomes true.
In the quorum-based approach, each site requests permission to execute the CS from
a subset of sites (called a quorum).
The quorums are formed in such a way that when two sites concurrently request
access to the CS, at least one site receives both the requests and this site is responsible
to make sure that only one request executes the CS at any time.
Distributed mutual exclusion algorithms
System model
The system consists of N sites, S1, S2, , SN . Without loss of generality, we assume
that a single process is running on each site
While waiting the process is not allowed to make further requests to enter the CS.
A site can be in one of the following three states: requesting the CS, executing the
CS, or neither requesting nor executing the CS
Distributed mutual exclusion algorithms
In the “requesting the CS” state, the site is blocked and cannot make further
requests for the CS.
At any instant, a site may have several pending requests for CS.
This is algorithm specific. We assume that channels reliably deliver all messages, sites
do not crash, and the network does not get partitioned
1. Safety property:
The safety property states that at any instant, only one process can execute the critical
section.
2.Liveness property :
In addition, a site must not wait indefinitely to execute the CS while other sites
are repeatedly executing the CS.
That is, every requesting site should get an opportunity to execute the CS in finite
time.
3. Fairness :
Fairness in the context of mutual exclusion means that each process gets a fair
chance to execute the CS.
In mutual exclusion algorithms, the fairness property generally means that the CS
execution requests are executed in order of their arrival in the system
Distributed mutual exclusion algorithms
Performance metrics
Message complexity : This is the 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
Response time : This is the time interval a request waits for its CS execution to be
over after its request messages have been sent out
Distributed mutual exclusion algorithms
Performance metrics
Lamport’s algorithm
Lamport developed a distributed mutual exclusion algorithm as an illustration of
his clock synchronization scheme
The algorithm is fair in the sense that a request for CS are executed in the order
of their timestamps and time is determined by logical clocks.
When a site processes a request for the CS, it updates its local clock and assigns
the request a timestamp.
then if the priority of pj’s request is lower, pi defers the REPLY to pj and sends
a REPLY message to pj only after executing the CS for its pending request.
Each process pi maintains the request-deferred array, RDi, the size of which is
the same as the number of processes in the system.
A site does not request permission from all other sites, but only from a subset of
the sites.
In quorum-based mutual exclusion algorithm, 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.
Therefore, a site Si locks all the sites in Ri in exclusive mode before executing its
CS.
Quorum-based mutual exclusion algorithms
Quorum-based mutual exclusion algorithms significantly reduce the message
complexity of invoking mutual exclusion by having sites ask permission from
only a subset of sites.
Since these algorithms are based on the notion of “Coteries” and “Quorums,”
we first describe the idea of coteries and quorums.
Intersection property
Minimality property
If “a” wants to invoke mutual exclusion, it requests permission from all sites
in its quorum “A.”
A site holding the token can enter its CS repeatedly until it sends the token to
some other site.
Depending upon the way a site carries out the search for the token, there are
numerous token-based algorithms
A site that possesses the token sends it to the requesting site upon the
receipt of its REQUEST message.
If a site receives a REQUEST message when it is executing the CS, it sends the
token only after it has completed the execution of the CS
Although the basic idea underlying this algorithm may sound rather simple,
there are two design issues that must be efficiently addressed:
In distributed systems, a process may request resources in any order, which may
not be known a priori, and a process can request a resource while holding
others.
Deadlocks can be dealt with using any one of the following three strategies:
deadlock prevention, deadlock avoidance, and deadlock detection.
System model
A process can be in two states, running or blocked. In the running state (also
called active state),
a process has all the needed resources and is either executing or is ready for
execution.
Detection of deadlocks
Since, in distributed systems, a cycle or knot may involve several sites, the search
for cycles greatly depends upon how the WFG of the system is represented across
the system.
Deadlock detection in distributed systems
Depending upon the way WFG information is maintained and the search for cycles is
carried out
Correctness criteria
A deadlock detection algorithm must satisfy the following two conditions:
1. Progress (no undetected deadlocks) : The algorithm must detect all existing
deadlocks in a finite time.
after all wait-for dependencies for a deadlock have formed, the algorithm should not
wait for any more events to occur to detect the deadlock
2. Safety (no false deadlocks) : The algorithm should not report deadlocks that do
not exist (called phantom or false deadlocks).
In distributed systems where there is no global memory and there is no global clock,
it is difficult to design a correct deadlock detection algorithm because sites may
obtain an out-of-date and inconsistent WFG of the system.
It involves rolling back one or more deadlocked processes and assigning their
resources to blocked processes so that they can resume execution
Deadlock detection in distributed systems
Models of deadlocks
Since the maximum out-degree of a node in a WFG for the single resource model can
be 1, the presence of a cycle in the WFG shall indicate that there is a deadlock
Deadlock detection in distributed systems
2. The AND model
In the AND model, a process can request more than one resource
simultaneously and the request is satisfied only after all the requested
resources are granted to the process.
The out degree of a node in the WFG for AND model can be more than 1.
The presence of a cycle in the WFG indicates a deadlock in the AND model.
3. The OR model
If all requests in the WFG are OR requests, then the nodes are called OR nodes.
Presence of a cycle in the WFG of an OR model does not imply a deadlock in the
OR model.
A generalization of the previous two models (OR model and AND model) is the
AND-OR model.
In the AND-OR model, a request may specify any combination of and and or in
the resource request.
For example, in the ANDOR model, a request for multiple resources can be of the
form x and (y or z).
Deadlock detection in distributed systems
4.
Another form of the AND-OR model is the ( p q )model (called the P-out-of-Q
model), which allows a request to obtain any k available resources from a pool of
n resources.
Every request in the model can be expressed in the AND-OR model and vice-versa
Deadlock detection in distributed systems
5. Unrestricted model
Only one assumption that the deadlock is stable is made and hence it is the most
general model.
This model helps separate concerns: Concerns about properties of the problem
(stability and deadlock) are separated from underlying distributed systems
computations (e.g., message passing versus synchronous communication).