Deadlocks can be avoided by clearly identifying safe states and unsafe states and requiring the system to keep enough resources in reserve to guarantee that all jobs active in the system can run to completion. The disadvantage of an avoidance policy is that the system’s resources aren’t allocated to their fullest potential
recovery: the steps that must be taken, when deadlock is detected, by breaking the circle of waiting processes.
Strategies for Handling Deadlocks
As these examples show, the requests and releases are received in an unpredictable order, which makes it very difficult to design a foolproof preventive policy. In general, operating systems use one of three strategies to deal with deadlocks:
• Prevent one of the four conditions from occurring (prevention).
• Avoid the deadlock if it becomes probable (avoidance).
• Detect the deadlock when it occurs and recover from it gracefully (detection).
Prevention
To prevent a deadlock, the operating system must eliminate one of the four necessary
conditions, a task complicated by the fact that the same condition can’t be eliminated from every resource
Mutual exclusion is necessary in any computer system because some resources such as memory, CPU, and dedicated devices must be exclusively allocated to one user at a time.
In the case of I/O