

There are three ways of handling deadlocks: Circular Wait: A set of processes (P1, P2….Pn) of waiting processes must exist such that P1 is waiting for resource that is held by P2, P2 is waiting for resource that is held by P3…Pn is waiting for a resource that is held by P1.Īs we have seen what is deadlock in os, now we need to see different methods to handle deadlock whenever it occurs.No Preemption: Once a process is holding a resource, then that resource cannot be taken away from the process until the process voluntarily releases it.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.If another process requests to use resource, the requesting process must be delayed until the resource has been released. At a time only one process can use the resource. Mutual Exclusion: A process should work in mutual exclusive way.Now, we will see what is necessary conditions for deadlock to occur.Ī deadlock situation can arise if the following 4 conditions hold simultaneously in a system – Till now, we have seen what is deadlock in os with an example. Note – There are 4 necessary conditions for deadlock. So, we can say that it is kind of deadlock or it is a deadlock situation. P1 is requesting for R2 but R2 is held by P2. Let us say R1 is allocated to P1 or P1 has taken R1.

In this figure, there are two resources R1 and R2 and two processes P1 and P2. For example, P1 –> R2 means Process P1 is requesting for resource R2. P –> R means process (P) is requesting for resource (R). For example, R2 –> P2 means resource R2 has been allocated to process P2. Note: R –> P means process (P) has taken the resource (R).
