Deadlock Prevention
To prevent deadlock, we can adopt a policy that eliminates one of the 4 conditions. How to do that? Let’s take a look at each condition.
Mutual Exclusion Must be supported by the OS, so can’t really be removed
Hold and Wait
- We can require a process request all of its required resources at one time (e.g, Ravenscar profile)
This is inefficient.
No Preemption
- We can require a process to release its resources and request again if it’s denied
- OS may preempt a process to require it releases its resources (⇒ no two processes have same priority)
- Requires saving and restoring state
Circular Wait
- Prevent by defining a linear ordering of resource types
- Lock resources following the ordering