what is deadlock in operating system? what are the conditions for deadlock?

 What is deadlock?

In computerize system processes request for resources. Resources may be memory space, files, input output devices .These mechanism is done by processor. If process waits then deadlock occur. If the available resources are less than the required resources. then also deadlock occur.

Conditions for deadlock are:

  • Mutual exclusion
  • Hold and wait
  • No preemption 
  • Circular wait
Mutual exclusion: If a resource can be used only by a one process at a time then it is known as mutual exclusion. Resource may have more than one instance or multiple instances . If mutual exclusion happens then deadlock occur.

Hold and wait: If a process holds a resource  and waiting for another resource then deadlock occur.

No preemption : There are two situation for processor. preemptive and non-preemptive condition.

non-preemptive condition means process go to the processor and not come to the processor, till it gets the output.

P2 waits for the resource held by  P4, P4  waits for resource held by P2.

Preemptive condition means process will automatically come from the processor so it allows other process to work on it. such that the process can be used by all the process at a time.

Which means if the non-preemptive condition happens then deadlock occur.

Circular wait : If the processes make a circular loop . for example if Po is waiting for a resource  held by P1, P1 is waiting for resource held by P2 , P2 is waiting for resource held by P3.and P3 is waiting for resource held by P1. So it make a circular loop. This type of mechanism is known as circular wait.

If circular wait is their then chances of deadlock is their.  



  







  






 

1 Comments

have you any doubt then ask.

Previous Post Next Post