Report on 
Deadlock Detection in Distributed 
Environment 
Distributed Systems 
CSE 601 
Submitted by 
Nadia Nahar BIT0327 
Submitted to 
Dr. Kazi Muheymin-Us-Sakib 
Associate Professor 
Institute of Information Technology 
University of Dhaka 
Submission Date 
16th September, 2013
Deadlock Detection is an important issue both in single processor system and distributed 
system. As distributed system is more complex than single processor one, deadlock detection 
is also different there, and the difficulty level is high. Before discussing this detection 
method, we need to first understand what deadlock actually is, and how it is different for 
distributed system. 
Deadlock 
Deadlock can be defined as a situation where no. of processors depends on each other for 
resource and ultimately no one can progress. In this kind of situation, each process waits for 
another process that is requested for a resource and this another process also waits for some 
other processes that is again dependent on the first process, and so this waiting becomes 
circular and no one can come out of the waiting state. 
Resource C 
belongs to 
needs 
Process A 
Process B 
Process C 
belongs to 
Resource A 
Resource B 
belongs to 
needs 
needs 
Figure: Deadlock 
In this figure, we can see that Process A is waiting for Process B, Process B waiting for 
Process C and Process C is waiting for Process A. This leads to a circular waiting and the 
system traps into a deadlock situation.
Deadlock in Distributed System 
Deadlock in a distributed system can be very tricky. In distributed system, processors are not 
in single machine, but in different. They do not share a common global memory, but 
communicate by message passing through communication links. There can be problem of 
message lost, duplication, time synchronization and many more. So detecting deadlock in 
distributed system can be real challenging. 
Deadlock Handling 
Deadlock handling can be done by one of three strategies – 
 Deadlock Detection & Recovery 
 Deadlock Prevention 
 Deadlock Avoidance 
Deadlock detection means that we will not try to stop system from being trapped in deadlock, 
but we will check if the system is trapped in one and then we will take necessary actions to 
unlock it. Deadlock prevention is when we take precautions before system deadlock has 
occurred. Deadlock avoidance refers to the strategy when we try to avoid deadlock by 
measuring safety conditions of the system state and allocating resources based on them. 
Deadlock avoidance is never used in distributed system. Because the information needed to 
allocate resources in DS is difficult to acquire at any point of time as different processes are 
not at the same machine. 
Deadlock prevention can be achieved either by having a process acquire all the needed 
resources simultaneously before it begins executing or by preempting a process which holds 
the needed resource. But these methods are not very efficient for distributed system. 
So, deadlock detection and recovery is the most used strategy to handle deadlock. Deadlock 
handling can be efficiently done by deadlock prevention and there are many approaches for 
it.
Deadlock Detection 
Several methods have been proposed for deadlock detection. The methods mentioned in the 
textbook (Distributed Operating System, Concepts and Design) are – 
1. Centralized Approach 
2. Hierarchical Approach 
3. Fully Distributed Approach 
i. WFG-Based Distributed Algorithm 
ii. Probe-Based Distributed Algorithm 
This report is not intended to describe these methods. So, I am not going for it. Rather, I am 
just going to discuss my idea about deadlock detection in distributed system. 
My Way 
There are two approaches in my mind about deadlock detection. 
The first one is to use a central node/ coordinator. In this approach, every machine will have a 
wait-for-graph or resource allocation graph for its own processes only. And the coordinator 
will merge all the wait-for-graphs of individual machines and will have an overall system 
wait-for-graph. It will take decisions about deadlock presence by viewing this linkage among 
processors of the system. Whenever an edge will change in the wait-for-graph of an 
individual machine, it will notify the coordinator and thus, the coordinator will be updated. 
The major problem of this approach will be single point failure. If the coordinator fails, there 
is no way to detect a deadlock in the system. 
coordinator 
Wait-for-graph 
(overall) 
Machine A 
Machine B 
Wait-for-graph 
(machine A) 
Wait-for-graph 
(machine B)
The second approach can be a notifying approach, where all the machines will broadcast its 
wait-for-graph to the others machine, whenever a change is made. So, all the machines will 
have an overall view of the system from the wait-for-graphs received by it. As a result, all the 
machines will be able to detect deadlocks in the system. And whenever, they detect one, they 
can also take decision about the recovery of the deadlock by discussing with each other. 
Wait-for-graph 
(overall) 
Wait-for-graph 
(overall) 
Wait-for-graph 
(overall) 
Machine A Machine B 
Machine C 
The problem of this approach is the overhead problem. The same computations are being 
done in all the machines, and also broadcasting of wait-for-graph in a regular basis can also 
cause extra traffic in communication link. 
Conclusion 
Deadlock detection in distributing system is not so simple as single machine deadlock 
detection process. There are many factors that need to be considered. The approaches 
mentioned in this document just came from an initiative thinking process about deadlock 
detection. To be honest, deadlock detection of distributed system can be a broad topic of 
research.

Deadlock detection

  • 1.
    Report on DeadlockDetection in Distributed Environment Distributed Systems CSE 601 Submitted by Nadia Nahar BIT0327 Submitted to Dr. Kazi Muheymin-Us-Sakib Associate Professor Institute of Information Technology University of Dhaka Submission Date 16th September, 2013
  • 2.
    Deadlock Detection isan important issue both in single processor system and distributed system. As distributed system is more complex than single processor one, deadlock detection is also different there, and the difficulty level is high. Before discussing this detection method, we need to first understand what deadlock actually is, and how it is different for distributed system. Deadlock Deadlock can be defined as a situation where no. of processors depends on each other for resource and ultimately no one can progress. In this kind of situation, each process waits for another process that is requested for a resource and this another process also waits for some other processes that is again dependent on the first process, and so this waiting becomes circular and no one can come out of the waiting state. Resource C belongs to needs Process A Process B Process C belongs to Resource A Resource B belongs to needs needs Figure: Deadlock In this figure, we can see that Process A is waiting for Process B, Process B waiting for Process C and Process C is waiting for Process A. This leads to a circular waiting and the system traps into a deadlock situation.
  • 3.
    Deadlock in DistributedSystem Deadlock in a distributed system can be very tricky. In distributed system, processors are not in single machine, but in different. They do not share a common global memory, but communicate by message passing through communication links. There can be problem of message lost, duplication, time synchronization and many more. So detecting deadlock in distributed system can be real challenging. Deadlock Handling Deadlock handling can be done by one of three strategies –  Deadlock Detection & Recovery  Deadlock Prevention  Deadlock Avoidance Deadlock detection means that we will not try to stop system from being trapped in deadlock, but we will check if the system is trapped in one and then we will take necessary actions to unlock it. Deadlock prevention is when we take precautions before system deadlock has occurred. Deadlock avoidance refers to the strategy when we try to avoid deadlock by measuring safety conditions of the system state and allocating resources based on them. Deadlock avoidance is never used in distributed system. Because the information needed to allocate resources in DS is difficult to acquire at any point of time as different processes are not at the same machine. Deadlock prevention can be achieved either by having a process acquire all the needed resources simultaneously before it begins executing or by preempting a process which holds the needed resource. But these methods are not very efficient for distributed system. So, deadlock detection and recovery is the most used strategy to handle deadlock. Deadlock handling can be efficiently done by deadlock prevention and there are many approaches for it.
  • 4.
    Deadlock Detection Severalmethods have been proposed for deadlock detection. The methods mentioned in the textbook (Distributed Operating System, Concepts and Design) are – 1. Centralized Approach 2. Hierarchical Approach 3. Fully Distributed Approach i. WFG-Based Distributed Algorithm ii. Probe-Based Distributed Algorithm This report is not intended to describe these methods. So, I am not going for it. Rather, I am just going to discuss my idea about deadlock detection in distributed system. My Way There are two approaches in my mind about deadlock detection. The first one is to use a central node/ coordinator. In this approach, every machine will have a wait-for-graph or resource allocation graph for its own processes only. And the coordinator will merge all the wait-for-graphs of individual machines and will have an overall system wait-for-graph. It will take decisions about deadlock presence by viewing this linkage among processors of the system. Whenever an edge will change in the wait-for-graph of an individual machine, it will notify the coordinator and thus, the coordinator will be updated. The major problem of this approach will be single point failure. If the coordinator fails, there is no way to detect a deadlock in the system. coordinator Wait-for-graph (overall) Machine A Machine B Wait-for-graph (machine A) Wait-for-graph (machine B)
  • 5.
    The second approachcan be a notifying approach, where all the machines will broadcast its wait-for-graph to the others machine, whenever a change is made. So, all the machines will have an overall view of the system from the wait-for-graphs received by it. As a result, all the machines will be able to detect deadlocks in the system. And whenever, they detect one, they can also take decision about the recovery of the deadlock by discussing with each other. Wait-for-graph (overall) Wait-for-graph (overall) Wait-for-graph (overall) Machine A Machine B Machine C The problem of this approach is the overhead problem. The same computations are being done in all the machines, and also broadcasting of wait-for-graph in a regular basis can also cause extra traffic in communication link. Conclusion Deadlock detection in distributing system is not so simple as single machine deadlock detection process. There are many factors that need to be considered. The approaches mentioned in this document just came from an initiative thinking process about deadlock detection. To be honest, deadlock detection of distributed system can be a broad topic of research.