Deadlock Prevention Methods
Deadlock can be prevented by stopping one of the four Deadlock Prevention Methods conditions from occurring that lead to deadlock.
Mutual Exclusion Condition
Removing the mutual exclusion condition means that no process will have exclusive access (rights) to a resource.
Hold and Wait Condition
The hold and wait or resource holding conditions may remove by requiring processes to request all the resources they will need before it begins execution. This advance knowledge is frequently difficult to satisfy and, in any case, is an inefficient use of resources. Another way is to require processes to request resources only when it has none. Thus, first, they must release all their currently held resources before requesting all the resources they will need for execution. This too is often impractical. It is so because resources may allocate and remain unused for long periods. Also, a process requiring a popular resource may have to wait indefinitely; as such a resource may always allocate to some process, resulting in resource starvation.
No Preemption Condition
If a process that is holding some resources requests another resource that cannot immediately allocate to it, then all resources currently being held released. Preempted resources added to the list of resources for which the process is waiting. A process will restart only when it can regain its old resources, as well as the new ones that it is requesting.
Circular Wait Condition
Approaches that avoid circular waits include disabling interrupts during critical sections and using a hierarchy to determine a partial ordering of resources and resources requested in the increasing order of the enumeration.