Distributed System – Types of Distributed Deadlock
A Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource occupied by some other process. When this situation arises, it is known as Deadlock.
A Distributed System is a Network of Machines that can exchange information with each other through Message-passing. It can be very useful as it helps in resource sharing. In such an environment, if the sequence of resource allocation to processes is not controlled, a deadlock may occur. In principle, deadlocks in distributed systems are similar to deadlocks in centralized systems. Therefore, the description of deadlocks presented above holds good both for centralized and distributed systems. However, handling of deadlocks in distributed systems is more complex than in centralized systems because the resources, the processes, and other relevant information are scattered on different nodes of the system.
Three commonly used strategies to handle deadlocks are as follows:
- Avoidance: Resources are carefully allocated to avoid deadlocks.
- Prevention: Constraints are imposed on the ways in which processes request resources in order to prevent deadlocks.
- Detection and recovery: Deadlocks are allowed to occur and a detection algorithm is used to detect them. After a deadlock is detected, it is resolved by certain means.
Types of Distributed Deadlock:
There are two types of Deadlocks in Distributed System:
Resource Deadlock: A resource deadlock occurs when two or more processes wait permanently for resources held by each other.
- A process that requires certain resources for its execution, and cannot proceed until it has acquired all those resources.
- It will only proceed to its execution when it has acquired all required resources.
- It can also be represented using AND condition as the process will execute only if it has all the required resources.
- Example: Process 1 has R1, R2, and requests resources R3. It will not execute if any one of them is missing. It will proceed only when it acquires all requested resources i.e. R1, R2, and R3.
figure 1: Resource Deadlock
Communication Deadlock: On the other hand, a communication deadlock occurs among a set of processes when they are blocked waiting for messages from other processes in the set in order to start execution but there are no messages in transit between them. When there are no messages in transit between any pair of processes in the set, none of the processes will ever receive a message. This implies that all processes in the set are deadlocked. Communication deadlocks can be easily modeled by using WFGs to indicate which processes are waiting to receive messages from which other processes. Hence, the detection of communication deadlocks can be done in the same manner as that for systems having only one unit of each resource type.
- In Communication Model, a Process requires resources for its execution and proceeds when it has acquired at least one of the resources it has requested for.
- Here resource stands for a process to communicate with.
- Here, a Process waits for communicating with another process in a set of processes. In a situation where each process in a set, is waiting to communicate with another process which itself is waiting to communicate with some other process, this situation is called communication deadlock.
- For 2 processes to communicate, each one should be in the unblocked state.
- It can be represented using OR conditions as it requires at least one of the resources to continue its Process.
- Example: In a Distributed System network, Process 1 is trying to communicate with Process 2, Process 2 is trying to communicate with Process 3 and Process 3 is trying to communicate with Process 1. In this situation, none of the processes will get unblocked and a communication deadlock occurs.
figure 2: Communication Deadlock