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

Deadlock

Deadlock occurs when a set of processes are blocked waiting for resources held by each other in a cyclic manner. There are four necessary conditions for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. There are three main methods to handle deadlock: prevention by ensuring conditions are never met, avoidance by allocating resources in a specific order, and detection and recovery by terminating processes or preempting resources when deadlock is detected. Most operating systems take the latter approach of ignoring deadlock.

Uploaded by

Jatin Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Deadlock

Deadlock occurs when a set of processes are blocked waiting for resources held by each other in a cyclic manner. There are four necessary conditions for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. There are three main methods to handle deadlock: prevention by ensuring conditions are never met, avoidance by allocating resources in a specific order, and detection and recovery by terminating processes or preempting resources when deadlock is detected. Most operating systems take the latter approach of ignoring deadlock.

Uploaded by

Jatin Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

A process in operating system uses resources in the following way.

1) Requests a resource

2) Use the resource

3) Releases the resource

Deadlock

A set of two or more processes are deadlocked if they are blocked (i.e., in the waiting
state) each holding a resource and waiting to acquire a resource held by another process
in the set.

or

A process is deadlocked if it is waiting for an event which is never going to happen.

Example:

 a system has two tape drives

 two processes are deadlocked if each holds one tape drive and has requested the
other

Conditions Necessary for Deadlock

All of the following four necessary conditions must hold simultaneously for deadlock to
occur:

 Mutual exclusion: only one process can use a resource at a time.


 Hold and Wait: a process holding at least one resource is waiting to acquire
additional resources which are currently held by other processes.
 No Preemption: A resource cannot be taken from a process unless the process
releases the resource. A resource can only be released voluntarily by the process
holding it.
 Circular Wait: a cycle of process requests exists (i.e., P0 is waiting for a resource
hold by P1 who is waiting for a resource held by Pj ... who is waiting for a resource
held by P(n-1) which is waiting for a resource held by Pn which is waiting for a
resource held by P0).

Circular wait implies the hold and wait condition. Therefore, these conditions are not
completely independent.

Methods for Handling Deadlock

The following are methods for addressing the possibility of deadlock:

 ensure that the system never enters a deadlocked state:


o deadlock prevention
o deadlock avoidance
 deadlock detection and recovery: allow the system to enter a deadlocked state,
then deal with and eliminate the problem
 ignore the problem: approached used by many operating systems including UNIX
and Windows, and the Java VM

Summary

 definition of deadlock
 three methods of addressing deadlock
o ensure deadlock never arises
 deadlock prevention: ensure at least one of the four necessary
conditions for deadlock never holds
 mutual exclusion
 hold and wait
 no preemption
 circular wait
 deadlock avoidance
 less stringent, but requires a priori information
 Banker's algorithm
o deadlock detection and recovery
 terminate processes: selecting a victim
 preempt resources
 selecting a victim
 rollback
 starvation
o ignore the problem (most common approach)

 there is no `silver bullet'


 often a combination of approaches should be employed to permit us to use an
optimal approach for each class of resources in the system

You might also like