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