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:
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:
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:
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:
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.