Deadlock can be defined formally as: a set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause. Because all the processes are waiting none of them will ever cause any of the events that could wake up any of the other members of the set and all the processes continue to wait forever.
In most cases, the event that each process is waiting for is the release of some resource currently possessed by another member of the set. In other words, each member of the set of deadlocked processes is waiting for a resource that is owned by deadlocked process. None of the processes can run, none of them can release any resources, and none of them can be awakened. The number of processes and the number and kind of resources possessed and requested are unimportant.
Conditions For Deadlock
Coffman et al. (1971) showed that four conditions must hold for there to be a deadlock;
1- Mutual exclusion condition. Each resource is either currently assigned to exactly one process or is available.
2- Hold and wait condition. Processes currently holding resources granted earlier can request new resources.
3- No preemption condition. Resources previously granted cannot be forcibly taken away for a process. They must be explicitly released by the process holding them.
4- Circular wait condition. There must be a circular chain of two or more processes, each of which is waiting for a resource held by the next member of the chain.
All four of these conditions must be present for a deadlock for a deadlock to occur. If one of them is absent, no deadlock is possible.