1. What a deadlock is and the four conditions
A set of processes is deadlocked when each is waiting for an event (usually a resource release) that only another process in the set can cause.
A deadlock can happen only if all four conditions hold at once (Coffman conditions):
- Mutual exclusion: at least one resource can be held by only one process at a time.
- Hold and wait: a process holds some resources while waiting for others.
- No preemption: a resource is released only voluntarily by its holder.
- Circular wait: there is a cycle where each waits for a resource held by the next.
They are necessary, not sufficient, in general.
Resource-allocation graph (RAG): circles for processes, boxes for resource types with one dot per instance. A request edge goes ; an assignment edge goes .
- If every resource has one instance: a cycle means deadlock, and no cycle means no deadlock.
- If some resource has several instances: no cycle still means no deadlock, but a cycle need not mean deadlock (another instance may be freed by a process outside the cycle).
With single instances you can collapse the RAG into a wait-for graph (edge if waits for a resource holds) and look for a cycle in .