Unit 6 : Distributed Deadlock Detection Distributed Systems
1. Unit 6 :
Distributed Deadlock Detection
Introduction,
Preliminaries,
Deadlock handling strategies in Distributed Systems,
Issues in Deadlock Detection and Resolution,
Control organizations for distributed deadlock
detection,
Centralized deadlock detection algorithms,
Distributed deadlock detection algorithms,
Avoidance and Prevention algorithms,
Hierarchical deadlock detection algorithms
2. Introduction
A distributed system is a network of sites that
exchange information with each other by message
passing.
In DS, a process can request and release resources
in any order, which may not be known prior and a
process can request some resources while holding
others.
if the sequence of the allocation of resources to
processes is not controlled in such environments,
deadlock can occur.
Several deadlock detection techniques based on
various control organizations are described in this
chapter.
3. Preliminaries
The problems of deadlocks has been generally
studied in DS under following model:
The system have only reusable resources.
Processes are allowed only exclusive access to
resources.
There is only one copy of each resource.
A process can be in 2 states: running or blocked.
In running (active) state, a process has all the needed
resources and is either executing or is ready for
execution.
In blocked state, a process is waiting to acquire some
resources.
4. 2 types of deadlocks:
Resource Deadlocks:
Process can simultaneously wait for several resources
and cannot proceed until they have acquired all those
resources.
A set of processes is resource-deadlocked if each process
in the set requests resources held by another process in
the set and must receive all of the requested resources
before it can become unblocked.
Communication Deadlocks:
In this, processes, communicate with other processes
among a set of processes.
A waiting process can unblock on receiving a
communication from any one of these processes.
Preliminaries (contd.)
5. A graph-theoretic model:
The state of a process-resource interaction is
shown by resource-allocation graph.
The node of this graph are processes and
resources of a system and edges of a graph
depict assignment or pending request.
A resource assignment is represented by an
assignment edge directed from the node of an
assigned resource to the node of the assigned
process
A system is deadlock if its resource allocation
graph contains a directed cycle or a knot.
Preliminaries (contd.)
6. In DS, the system state can be modeled or
represented by a directed graph, called a wait-
for-graph(WFG).
In DDBS, users access the data objects of the
database by executing transactions.
A transaction can be viewed as process that
performs a sequence of reads and writes on the
data objects.
In DDBS, WFG is referred as transaction- wait-for
graph(TWF graph)
Preliminaries (contd.)
7. Deadlock handling strategies in Distributed
Systems
Deadlock handling is complicated to implement
in DS because no one site has accurate
knowledge of the current state of the system so
involve finite and unpredictable delay.
3 deadlock handling strategies are:
Deadlock prevention
Deadlock avoidance
Deadlock detection
8. Deadlock prevention
It is commonly achieved by either having a process
acquire all the needed resources simultaneously
before it begins execution or by preempting a
process that holds the needed resources.
In this, a process requests(or releases) a remote
resource by sending request message to the site
where the resource is located.
Some drawbacks of this are listed below:
It is inefficient as it decreases the system
concurrency.
A set of resources can become deadlocked in the
resource acquiring phase.
In many systems, future resource requirements are
unpredictable.(i.e. not known a priori).
9. A resource is granted to a process if the resulting
global system (including all the processes and
resources of DS) is safe.
Problems causing deadlock avoidance are:
1. Every site has to maintain information on global
state of the system, which translates into huge
storage requirements and extensive
communication costs
2. The process of checking for a safe global state
must be mutually exclusive. This restriction will
severely limit the concurrency and throughput of
the system.
3. Due to large number of processes and resources,
it will be computationally expensive to check for
Deadlock Avoidance
10. It requires an examination of the status of
process-resource interactions for the presence of
cyclical wait.
Deadlock detection in DS has 2 favorable
conditions:
1.Once a cycle is formed in WFG, it persists until
it is detected and broken.
2.Cycle detection can proceed concurrently with
the normal activities of a system.
Deadlock Detection
11. Issues in Deadlock Detection and Resolution
Deadlock detection has 2 basic issues:
Detection of existing deadlocks
Resolution of detected deadlocks.
Detection:
2 issues: 1) maintenance of WFG
2) search of the WFG for the presence of cycles.
Depending upon manner in which WFG information
is maintained , the search for cycles is carried out.
There are centralized, distributed and hierarchical
algorithms for deadlock detection.
12. A correct deadlock detection algorithm must satisfy following
conditions:
Progress-No Undetected deadlocks.
The algo. must detect all existing deadlocks in finite time.
Once a deadlock has occurred the deadlock detection activity
should continuously progress until the deadlock is detected.
Safety-No False deadlocks.
The algo. should not report deadlocks which are non-existent
Called as Phantom deadlocks.
Resolution:
It involves breaking existing wait-for dependencies in the system
WFG to resolve the deadlock.
Several deadlock detection algo. Propogate information regarding
wait-for dependencies along the edges of the wait-for-graph.
So when wait-for dependency is broken, the corresponding
information should be immediately cleaned from the system.
If it is not cleaned properly in a timely manner, it may result in
detection of Phantom deadlocks.
Issues in Deadlock Detection and Resolution
13. Control organizations for distributed
deadlock detection
Centralized control:
In this a designated (control) site has responsibility of
constructing the global WFG and searching it for cycles.
These are conceptually simple and easy to implement.
Here the control site has complete information about
the deadlock cycle and it can thus optimally resolve the
deadlock.
But it has single point of failure: communication links
near the control site are likely to be congested because
the control sites receives WFG information from all
other sites.
Also, message traffic generated due to deadlock
detection activity is independent of the rate of deadlock
formation and structure of the deadlock cycles.
14. Distributed control:
In this the responsibility of detecting global deadlock is
shared equally among all sites.
The global state graph is spread over many sites and
several sites participate in the detection of global cycles.
In this, control is not vulnerable to a single point of
failure and no site is swamped with deadlock detection
activity.
These algorithms are difficult to the lack of globally
shared memory.
Also in this several sites may initiate deadlock detection
for the same deadlock.
Proof of correctness is difficult for these algorithms.
Control organizations for distributed
deadlock detection
15. Hierarchical control:
In this sites are arranged in a hierarchical fashion
and site detects deadlocks involving only its
descendent sites.
These require special care while arranging all sites
the sites in the hierarchy.
For efficiency, most deadlocks should be localized
to as few clusters as possible.
Control organizations for distributed
deadlock detection
16. Centralized deadlock detection algorithms
The completely centralized algorithm:
Designated site is called control site
Maintains the WFG of the entire system and checks for existence
of deadlock cycles.
All sites request or release resources by sending request resource
or release resource messages.
Accordingly WFG will be updated
Simple and easy to implement
Highly inefficient because all resource acquisition and release
request must go through the control site, even when resource is
local.
It results in large delays in responding to user requests, large
communication overhead and congestion of communication
links near the control site.
Reliability is poor because if control site fails, the entire system
come to halt because all the status information resides at the
control site.
17. The completely centralized algorithm (contd.):
Due to inherent communication delays and lack of
perfectly synchronised clocks, the designated site
may get an inconsistent view of the system and
detect false deadlocks.
T1 (S3) T2(S4)
Lock R1 Lock R1
Unlock R1 Unlock R1
Lock R2 Lock R2
Unlock R2 Unlock R2
Centralized deadlock detection algorithms
S1
R1
S2
R2
Designated
Site
T2 T1
T1 T2
T1-> T2 -> T1
18. The Ho-Ramamoorthy Algorithm:
Two-phase algorithm
One-phase algorithm
These algorithms collect two consecutive status
reports or keep two status tables at each site gets a
consistent view of the system.
Centralized deadlock detection algorithms
19. The Ho-Ramamoorthy Algorithm:
Two-phase algorithm
Every site maintains a status table that contains all
the processes initiated at that site
Includes all resources which are locked and in
waited condition
Periodically WFG is constructed at designated site
If no cycle -> system is free from deadlock
If cycle -> request for status table from all sites &
again construct WFG using only those
transactions which are common to both reports. If
same cycle is detected, the system is declared
deadlock.
Centralized deadlock detection algorithms
20. The Ho-Ramamoorthy Algorithm:
One-phase algorithm
Requires only one status report from each site.
Each site maintains 2 status tables:
resource status table : keeps track of the transactions
that have locked or are waiting for resources stored at
that site.
process status table : keeps track of the resources
locked by or waited for by all the transactions at that
site.
It does not detect false deadlocks because it
eliminates the inconsistency in state information
by using only the information that is common to
both tables.
Centralized deadlock detection algorithms
21. Distributed deadlock detection algorithms
Algorithms can be divided into 4 classes:
Path-pushing
Edge-chasing
Diffusion computation
Global state detection
22. Distributed deadlock detection algorithms
Path-pushing Algorithms :
Wait for dependency information of the global WFG is
disseminated in the form of paths (i.e. sequence of wait-for
dependency edges)
This algorithm sends n(n-1)/2 messages to detect a
deadlock involving n sites.
Size of message is O(n).
Delay detecting deadlock is O(n)
23. Distributed deadlock detection algorithms
Edge-chasing Algorithms :
Special messages called probes are circulated along the
edge of the WFG to detect a cycle.
When a blocked process receives a probe, it propagates the
probe along its outgoing edge in WFG.
A process declares a deadlock when it receives a probe
initiated by it.
Here probes are of fixed size
25. Distributed deadlock detection algorithms
Diffusion Computation Based Algorithms :
It make use of Echo algorithm to detect deadlocks.
For this, process sends out query message along all the
outgoing edges in WFG.
Queries are discarded by running process and are echoed
back by blocked processes in the following way:
When a blocked process receives first query message for a
particular deadlock detection initiation, it does not send a
reply message until it has received a reply message for
every query it has sent.
For all subsequent queries, it immediately sends back a
reply message.
The initiator of a deadlock detection detects a deadlock
when it receives a reply message for every query it sent.
26. Distributed deadlock detection
algorithms
Global State Detection Based Algorithms :
It has following facts:
A consistent snapshot of DS can be obtained
without freezing the underlying computation.
A consistent snapshot may not represent the
system state at any moment in the time, but if a
stable property holds in the system before the
snapshot collection is initiated, this property will
still hold in the snapshot.
27. Hierarchical deadlock detection algorithms
Sites are (logically) arranged in the hierarchical
fashion.
A site is responsible for detecting deadlocks
involving only its children sites
These algorithms take advantage of access
patterns that are localized to a cluster of sites to
optimize performance.
28. Hierarchical deadlock detection algorithms
The Menasce-Muntz algorithm:
All the controllers are arranged in tree fashion
The controllers at bottommost level (leaf controllers)
manage resources, and other (non-leaf controllers)
responsible for deadlock detection
Whenever a change occurs in a controller’s TWF graph
due to resource allocation, wait or release is propagated
to its parent controller
The parent controller makes changes in its TWF graph,
searches for cycles, and propagates the changes upword,
if necessary
A non-leaf controllers can receive up-to-date
information concerning the TWF graph of its children
continuously
29. Hierarchical deadlock detection algorithms
The Ho- Ramamoorthy algorithm:
Sites are grouped into several disjoint clusters.
A site is chosen as central control site which dynamically
chooses a control site for each cluster
A central control site request from every control site their
intercluster transaction status information and wait for
relations