0% found this document useful (0 votes)
4 views

Deadlock Notes

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Deadlock Notes

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Deadlock notes

Def

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.

Diagram

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

• 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.
2. 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.

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

Deadlock Detection in Distributed Systems

Completely Centralized Algorithm

• In a network of n sites, one site is chosen as a control site. This site is responsible for
deadlock detection.
• The major drawbacks of this technique are as follows:
a. A site has to send requests even for using its own resource.
b. There is a possibility of phantom deadlock.

Two-Phase Algorithm

This technique reduces the possibility of phantom deadlock but on the other hand time
consumption is more.

One Phase Algorithm

This technique reduces time consumption but space complexity increases.

Conditions for Deadlock

1. Mutual Exclusion
this condition implies the existence of atleast one resource in the system which can be used
by only one process at a given point in time
• Hold and wait: This condition implies the existence of a process holding some resources and
waiting for another one that is held by some other process in the system. For example, if a
process P1 is having resource R1 and at the same time, it can request another resource R2
which is currently allocated to process P2.

No Preemption: This condition implies that resources once allocated to a process cannot be
taken away until and unless the process voluntarily releases them.

Circular wait: This condition refers to the waiting of processes in a circular manner where
the last process waits for the resource which is held by the first one.

Prevention of deadlock

Deadlock can be prevented by two ways


1. Ordered request
The Method makes sure that the Circular Wait condition is not reached and if one of the
deadlock conditions is denied, the deadlock will be prevented.
2. Collective request

In both of the above Resource Allocation Policies, the Hold and Wait
condition of Deadlock can’t be reached and thus the Deadlock is
prevented.

You might also like