Anyway, I am studying deadlocks right now. The formal definition (unlike most formal definitions!) is quite easy to comprehend: 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.
But all of the conditions below should hold for a deadlock to occur:
- Mutual exclusion: Each resource is either currently assigned to exactly one process or is available.
- Hold and wait: Processes currently holding resources that were granted earlier can request new resources
- No preemption: Resources already granted cannot be forcibly taken away from a process. (The process has to explicitly release them.)
- Circular wait: 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.
The 'directed graph' technique is used to model these conditions. All approaches that attempt to prevent deadlocks try and eliminate one or more of the above conditions.