Resource Deadlocks vs Communication Deadlocks in Distributed Systems


Deadlock in an operating system happens when a process gets into a waiting state as other processes hold the resources which need to be used. This problem generally happens during multi-processing environments, distributes systems, and parallel computation systems.

In distributed systems, deadlocks are considered the major problem, where the resources requested by the process are not available due to other processes holding onto it. A distributed system contains a set of processes p1,p2,p3…pn that do not share a common memory, and communication is made only by passing messages through the network. This does not have a global clock for instant access and communication medium. Each process has two states such as a running state where the process contains all the resources and is ready for execution and another state a blocked state where the process is in a waiting state needing some resources.

Below are the four conditions that need to be met for the deadlock to occur −

Hold and wait  one process holds the resources that are needed for another process to use.

Mutual exclusion − when only one process is allowed to use one resource at a time.

No preemption − No process cannot be preempted until it completes the execution of a task.

Circular wait − The process needs to wait for the required resource in a cyclic manner, where the last process in the queue waits for the resource used by the first process.

ResourceDeadlock 

Resource deadlock occurs when a process is waiting for the set of resources that is held by another process and it waits to receive all the resources requested before it becomes unblocked. So, the process set which waits for resources is said to be in a resource deadlock state. Consider an example when two processes P1 and P2 and are in need of resources X and Y. In this case, P1 waits for resource Y where P2 holds resource Y, and P2, in turn, waits for resource X which has to be released by P1 holding it. So, in a

closed manner, P1 needs resource Y and waits for P2 to release it, and P2 needs X, and waits for P2 to release it.

The above figure is said to be in a resource deadlock since each process waits for another process to acquire all the needed sets of resources. Distributed deadlocks are more difficult to handle because resources and the input process are distributed and cannot be detected at a commonplace. Few approaches are used to handle distributed deadlocks such as detection, prevention, avoidance, and ostrich problem (avoidance).

Communication deadlock

Communication deadlock happens among process which needs to communicate and waits for another process for its task. The process which is in a waiting state can unblock itself when it receives communication requests from other processes in the group. When each process in the set waits for another process to communicate, at this time no other process starts other communication until it receives further communication from the initial process.

Consider a scenario when process X waits for messages from process Y and process Y in turn waits for messages from another process called Z. Then process Z waits for the initial process. This deadlock occurs when communication among the process is locked by each other

The table below defines the major differences between resource and communication deadlock:

Basis of difference

Resource Deadlocks

Communication Deadlocks

Definition

The process waits for the several resources that are on hold by other processes

The process waits for another process in the group to initiate communication with one another

Process state

A process that is waiting for needed resources cannot continue to its execution state until acquiring all of it.

The process will not enter into an execution state till it receives a communication message from another process.

Waiting for

The process waits for resources to perform its task.

The process waits for the messages from another process.

Transaction

No information is known about the dependency between the transactions

The process can identify which process to communicate before beginning the transaction

Deadlock occurrence

When each process in a specific set needs multiple resources from another process, and initial process has to unblock itself by fetching the needed resources. Then these set of processes are inside resource deadlock

When each process in the group waits for communication from another process and during this phase, no other process initiates new communication until it receives the same from the needed process, these processes are now in a deadlock phase.

Examples

Process P1 waits for resource X and P2 waits for resource Y and each process holds and waits for each of the resources.

Process X waits for a message from process Y, which in turn waits for process Z and Z waits for initial process X.

Conclusion

Deadlock occurrence in distributed systems is a major issue as resources do not share a common memory location and they are distributed among different processes. Two types of deadlocks are possible in a distributed system in terms of resource and communication, each of them is described above along with the differences between them.

Updated on: 17-Jul-2023

276 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements