Deadlock: 

When a process requests resources; if the resources are not available the process enters a waiting state. A waiting process never again changes its state because the resources it has requested are held by other waiting processes. This situation is called a deadlock.


Example Of Deadlock:

  a) Suppose System has 2 disk drives. And Processes P1 and P2 each hold one disk drive and each needs another one.

 b) Semaphores A and B, initialized to 1 and processes P0 and P1 initialized following operations on semaphore A and B then leading deadlock situation.   

P0 P1 wait (A); wait(B) wait (B); wait(A)  


Necessary Conditions: 

A deadlock situatin can arise if the following four conditions hold true simultaneously in a system.


a) Mutual exclusion: Atleast one resource must be held in a non sharable mode; i.e only one process at a time can use the resource. If another process requests that resource, the requesting process must be delayed till the resource is released. 

b) Hold and wait: A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes. 

c) No preemption: Resources cannot be preempted; that is, a resource can be released only voluntarily by the process holding it after its task is completed. 

d) Circular wait: A set {P0, P1,…., Pn } of waiting processes must exist such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2,….., Pn-1 is waiting for a resource held by Pn, and Pn is waiting for a resource held by P0. 



Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post