Deadlock in Operating System (OS)

Deadlock Introduction in Operating System

Important Features of Deadlock –

Deadlock refers to the condition when 2 or more processes are waiting for each other to release a resource indefinitely. A process in nature requests a resource first and uses it and finally releases it.

But in deadlock situation, both the processes wait for the other process . Let’s look at one example to understand it – Say, Process A has resource R1 , Process B has resource R2. If Process A request resource R2 and Process B requests resource R1, at the same time , then deadlock occurs.

Deadlock in OS Operating System

More Facts

  • In deadlock, processes get blocked because each process is holding some resource and they are waiting for other resource , which is held by another process.
  • Deadlock usually occurs in multiprocessing, time- sharing etc
  • In Multiprocessing, many processes share a specific type of mutually exclusion resource known as soft lock.
  • Time Sharing computers are equipped with a hardwired lock which gaurantees exclusive access  to processes , thus preventing deadlock.
  • There is no general solution to avoid soft deadlock.

Conditions for Deadlock

Deadlock can occur if all the given 4 conditions ( Coffman Conditions ) are satisfied, that is if all are true  :

  • Mutual Exclusion
  • Hold and Wait
  • No Preemption
  • Circular wait
Deadlock Conditions in OS Operating System

Let’s look at each one in detail :

  1. Mutual exclusion – If  At least one or more resource are in non shareable mode , the resources should be in mutual exclusion. Non Shareable means , resource can’t be used by more than 1 process at a time, unless the resource gets released.
  2. Hold and Wait – Processes which are already holding at least 1 resource may request new resource.
  3. No Pre emptive condition – Resources can’t be released by force , only the process holding the resource can release it, which does so after the process has finished its task.
  4. Circular wait – 2 or more process form  a circular chain where each process waits and  want to acquire the resource which the next process in the chain holds.

Further reading –

Please Login/Signup to comment