Chapter 2 (English)
10. Avoidance & Prevention
Avoidance & Prevention
Deadlock prevention and avoidance are operating system techniques to handle deadlocks—situations where processes are stuck waiting for each other. Prevention structurally eliminates one of the four necessary deadlock conditions (mutual exclusion, hold & wait, no preemption, circular wait), while Avoidance dynamically checks resource requests to ensure the system remains in a "safe state".
GeeksforGeeks +3
GeeksforGeeks +3Deadlock Prevention Methods
These methods break one of the four Coffman conditions, most commonly by imposing resource ordering:
GeeksforGeeks +3
These methods break one of the four Coffman conditions, most commonly by imposing resource ordering:
GeeksforGeeks +3- Eliminate Hold and Wait: A process must request all required resources at once, or release held resources before requesting new ones.
- Eliminate Mutual Exclusion: Make resources shareable (e.g., spooling), although many resources must remain mutually exclusive.
- Eliminate No Preemption: If a process holds resources and requests another that cannot be immediately allocated, it must release all currently held resources.
- Eliminate Circular Wait: Impose a strict, unique ordering of resource types; processes must request resources in increasing numerical order.
GeeksforGeeks +4
Deadlock Avoidance Techniques
This requires prior knowledge of maximum resource needs to dynamically analyze if granting a request keeps the system in a safe state:
e-Adhyayan +1
This requires prior knowledge of maximum resource needs to dynamically analyze if granting a request keeps the system in a safe state:
e-Adhyayan +1- Safe State Calculation: Before allocating a resource, the OS simulates the request to ensure a "safe sequence" exists where all processes can finish.
- Banker's Algorithm: Used for multiple instances of resource types to determine if allocating a resource keeps the system safe.
- Resource Allocation Graph (RAG): Used for single instances of resource types to detect potential cycles.
GeeksforGeeks +4
- Prevention is strict, conservative, and works by making a deadlock condition impossible.
- Avoidance is more flexible, allowing higher resource utilization by dynamically checking if a "safe" state is maintained.