Definition
Coffman Conditions
The Coffman conditions are a set of four necessary requirements that must hold simultaneously for a deadlock to occur in a system. They were first identified by Edward G. Coffman, Jr. in 1971.
For a deadlock to exist, all four of the following conditions must be present:
- Mutual Exclusion: At least one resource must be held in a non-shareable mode; only one process can use the resource at any given time.
- 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.
- No Preemption: Resources cannot be forcibly removed from the processes holding them; they must be released voluntarily by the process after it has completed its task.
- Circular Wait: A closed chain of processes exists such that each process holds at least one resource needed by the next process in the chain.
Prevention and Avoidance
Deadlock management strategies often focus on breaking at least one of these four conditions:
- Breaking Mutual Exclusion: Spooling resources or using shareable data structures where possible.
- Breaking Hold and Wait: Requiring processes to request all resources at once or release held resources before requesting new ones.
- Breaking No Preemption: Allowing the OS to forcibly take resources from a process if needed.
- Breaking Circular Wait: Imposing a linear ordering of resource types and requiring processes to request resources in an increasing order of enumeration.