Advertisement

DEADLOCKS in Operating System and Deadlock Characterization

DEADLOCKS in Operating System

A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause. If process A is waiting for a resource that process B has, and process B is waiting for a resource that process A has, then both the processes are deadlocked.

Resources are of two types

1. Preemptable
2. Non-preemptable

A preemptable resource can be taken away from the process that owns it. A non-preemptable resource cannot be taken from its current owner.

Deadlocks generally occur in non-preemptable resources. Deadlocks that involve preemptable resources can be avoided on resolved by the reallocation of resources. The sequence in which resources are required is:

i. Requested the resource
ii. Use the resource
iii. Release the resource

If the resource is not available, when a process requested for it, then the process will start waiting, so that wherever that resource becomes available, the requesting process can use it. The resource can be a hardware device (type drive) or source information  (a record in a file).

Deadlock Characterization

various deadlock characterization in the operating system
A deadlock can occur if following four conditions hold simultaneously.

i) Mutual Exclusion Only one process should be using the resource and if another process requests that resource, then the requesting process should be delayed until the resource is released.

ii) Hold and Wait There should be a process that is holding a resource and is waiting for one or more resources that are in use by other processes.

iii) Non-Preemption Resources cannot be preemptive. A process will release the resource only when it has completed its task.

iv) Circular Wait There should a circular chain of two or more processors. Each of which is waiting for a resource held by the next process in the chain.


A deadlock is not possible if any of these four conditions described earlier are absent. So all the four conditions must hold simultaneously for a deadlock to occur.