What are the necessary conditions for deadlocks?
1.Mutual exclusion: Only one process at a time is able to use the resource.
2.Hold and wait: A process should be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes.
3.No preemption: Resource cannot be preempted that is, a resource is able to be released only voluntarily by the process holding it, subsequent to that process has completed its task.
4.Circular wait:A set {p0,p1,.........,pn} of waiting processes should exit such that p0 is waiting for a resource that is held by p1 and p1 is waiting for a resource that is held by p2,.........,pn-1 is waiting for a resource that is held by pn, and pn is waiting for a resource that is held by p0.