Home » Difference between Resource Deadlocks and Communication Deadlocks in Distributed Systems

Difference between Resource Deadlocks and Communication Deadlocks in Distributed Systems

by Online Tutorials Library

Difference between Resource Deadlocks and Communication Deadlocks in Distributed Systems

A deadlock is a condition where a process cannot proceed because it needs to obtain a resource held by another process, and it itself is holding a resource that the other process needs. Four requirements must be met for a deadlock to occur:

  1. Mutual Exclusion: At least one resource in the system must be able to be used by only one process at a time.
  2. Hold & Wait: There must be a process that retains a resource while waiting for another resource acquired by some other process.
  3. No Preemption: It means that resources cannot be taken forcefully from one process and handed over to another.
  4. Circular Wait: All processes must wait for the resource in a cyclic fashion, with the last process waiting for the first process’s resource.

Resource Deadlocks vs Communication Deadlocks in Distributed Systems

What is Distributed System Deadlocks?

Deadlocks in distributed systems are similar to deadlocks in single-processor systems. They are not easy to avoid, prevent, detect, and harder to cure when tracked down because all the relevant information is scattered over many machines. Some systems, such as distributed database systems, can be extremely serious, so it is important to understand how they differ from ordinary deadlocks.

There are two kinds of distributed deadlocks, communication deadlocks, and resource deadlocks. A communication deadlock occurs when process A is trying to send a message to process B, which is trying to send one to process C, which is trying to send one to A. There are various scenarios in which this situation leads to a deadlock, such as no buffers being available. A resource deadlock occurs when processes fight exclusive access to I/O devices, files, locks, or other resources.

Various strategies are used to handle deadlocks. Dealing with deadlocks can be done in the following ways, such as:

  • Ignore the problem: We can choose to ignore the issue. One of the most popular options is this.
  • Detection: Allowing deadlocks to occur, then detecting that there is a deadlock in the system, and finally dealing with the deadlock. Deadlock detection requires examining the status of process-resource interactions for the presence of cyclic wait. Deadlock detection in distributed systems seems to be the best approach to handle deadlocks in distributed systems.
  • Prevention: We can impose resource allocation limits to prevent deadlocks. Deadlock prevention is commonly achieved by having a process acquire all the needed resources simultaneously before it begins executing or by preempting a process that holds the needed resource.
  • Avoidance: In the deadlock avoidance approach to distributed systems, a resource is granted to a process if the resulting global system state is safe. However, deadlock avoidance is impractical in distributed systems due to several problems.

Deadlock avoidance is not used in distributed systems. The difficulty with deadlock avoidance is that the algorithm will need to know resource use requirements ahead of time to schedule them correctly.

All four are potentially applicable to distributed systems. Deadlock handling becomes highly complicated in distributed systems because no site has accurate knowledge of the system’s current state and because every inter-site communication involves a finite and unpredictable delay.

What is Resource Deadlock?

In resource deadlocks, processes 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 it must receive all of the requested resources before it can become unblocked. This is called resource deadlock.

For example, suppose a system is running 2 processes, P1 & P2, and they want the resources R1 & R2. The resource allocation graph is shown below:

Resource Deadlocks vs Communication Deadlocks in Distributed Systems

But here, the P1 process holds resource R1 & waits to get R2 resource while process P2 holds resource R2 & waits to get R1 resource. In this way, P1 waits for P2 to complete & P2 waits for P1 to get complete & hence a deadlock.

What is Communication Deadlock?

Processes in this deadlock wait to communicate with other processes in a group of processes. A waiting process can unblock on receiving communication from any of these processes. If each process in the set is waiting to communicate with another process in the set, and no process in the set ever begins any additional communication until it receives the communication for which it is waiting, the set is communication-Deadlocked.

For Example: Suppose, process A waits to get a message from process B, Process B waits to get a message from process C, and Process C waits to get a message from process A and hence a deadlock. The TFW diagram is shown below:

Resource Deadlocks vs Communication Deadlocks in Distributed Systems

Users in a distributed system (DDBS) access the database’s data objects by executing transactions. A transaction can be thought of as a series of reads and writes performed on data objects. A database’s data objects can be considered resources that are acquired (through locking) and released (through unlocking) by transactions. In DDBS, wait for the graph is referred to as transaction-wait-for-graph (TWF Graph)

Difference between Resource Deadlock and Communication Deadlock

In resource deadlocks, processes access resources, such as data objects in database systems and buffers in store and forward communication networks. A process acquires a resource before accessing it and releasing it after using it. A process that requires resources for execution cannot proceed until it has acquired all those resources. A set of processes is resource deadlocked if each process in the set requests a resource held by another process in the set.

In communication deadlocks, messages are the resources for which processes wait. Reception of a message takes a process out of wait and unblocks it. A set of processes is communication deadlocked if each process in the set is waiting for a message from another process in the set and no process in the set ever sends a message. Below are some more differences between resource deadlock and communication deadlock.

Resource Deadlock Communication Deadlock
It is not directly known which transaction depends on which other transaction. In the communication model, before a process can continue, it may know the identification of the processes from which it must receive a message to communicate.
In the resource allocation model, a process cannot proceed with the execution until it receives all the resources for which it is waiting. In the communication model, a process cannot proceed with the execution until it can communicate with one of the processes it is waiting for.
Waiting (by processes) is done for resources. Waiting (by processes) is done for messages.
If each process in the set seeks resources held by another process in the set and must obtain all the requested resources before it can become unblocked, the process set is resource deadlocked. If each process in the set is waiting to communicate with another process in the set, and no process in the set ever begins any additional communication until it receives the communication for which it is waiting, the set is communication Deadlocked.
Resource deadlock can be prevented by a safe state. Communication deadlock cannot be prevented by a safe state.

You may also like