Search your topic here

Deadlock

DEADLOCK:


Deadlock is a set of blocked processes each holding a resource and waiting for a resource held by another process.

Necessary condition for deadlock to occur-

1) Mutual exclusion- There must be at least one resource in the system which can not  be shared simultaneously more than one processes.

2) Hold and wait condition-that is the processes request for additional resources while holding other resources.

3) No preemption-That is, once a resource is allocated to a particular process that resource can not be preempted, the process has to relieve the resource on completion.

4) Circular wait- Circular wait is nothing but an extension of hold and wait condition.

If all these four condition exist simultaneously in a system than the  system may lead to deadlock.
For example:
Imagine about a pic about traffic on a square in a city.
See below, a queue of cars is crossing the road.
We gives this row name Queue 1.
At this time Queue 1 gets easily passes from the square.


See in second below image,
There is a condition when Queue 1 needed to be wait for Queue to to get pass first from square. Till that Queue 1 is in wait state.

See in third below image,
There is a condition when Queue 2 needed to be wait for Queue 3 to get pass first from square. Till that Queue 2 is in wait state, so become Queue 1 also in wait state.

See in fourth below image,
There is a condition when Queue 3 needed to be wait for Queue 4 to get pass from the square,
But Queue 4 is waiting for Queue 1, and Queue 1 for Queue 2, and Queue 2 for Queue 3, and Queue 3 for Queue 4 and so on.

So this is the deadlock.

DEADLOCK PREVENTION:

Deadlock prevention algorithm ensure that at least one of the condition of deadlock detection (Mutual exclusion, Hold and wait, No preemption, Circular wait) should not hold true.



Deadlock prevention is possible, but most of the deadlock prevention algorithms have poor resource utilization and as a result leads to reduced throughputs.

LEAVE A REPLY