Deadlock in OS

  • by
Deadlock meaning in OS:

The main reason is to occur deadlock in OS is, in multi-programming environment several processes request the resources from OS. If the resources are available at that time, then OS permits the resources to that process, if not available then process has to wait until resources are released. Because not releasing the resources are blocked by others. This situation is said to be deadlock

Deadlock Definition:

According to P. B. Prasad, “A process request” the resources, the resources are not available at that time, so the process enters into the waiting state. The requesting resources are held by another waiting process, both processes are in waiting state, this situation is called as deadlock”.

Deadlocks are a set of blocked processes each holding a resource and waiting to acquire a resource held by another process.

Example of Deadlock:

P1 and P2 are two processes

R1 and R2 are two resources

P1 request the resources R1 which is already held by process P2.

P2 request the resources R2 which is already held by process P1.

Then both process enters in to the waiting state. There is no work progress or release of resources which leads to deadlock situation.

Deadlock Resource Allocation Graph:

Deadlock can be represented by resource allocation graph.

It is also called as deadlock diagram

Here, Process represented by circle

Resources represented by square

Edges represented for requesting and assigning

Deadlock Conditions in OS:

A deadlock system must satisfy the following 4 conditions. Conditions for deadlock are as:
1] Mutual Exclusion

2] Hold and Wait

3] No preemption

4] Circular wait

1] Mutual Exclusion:

Mutual exclusion means resources are (at least one) in non-sharable mode only.

It means only one process at a time can use a resource.

2] Hold and Wait:

Each process in the deadlock state must hold at least one resource and is waiting for additional resource that are currently being held by other processes.

3] No preemption:

Resources are not released in the middle of the work, they released only after the process has completed its task.

4] Circular wait:

All the processes must wait for the resource in a cyclic manner where the last process waits for the resource held by the first process.

Leave a Reply