Deadlocks — classic algorithms: Banker's algorithm for resource allocation is used for which purpose?
-
Adeadlock prevention
-
Bdeadlock avoidance
-
Cdeadlock recovery
-
Dmutual exclusion
-
ENone of the above
Answer
Correct Answer: deadlock avoidance
Explanation
Introduction / Context:Deadlocks occur when processes wait indefinitely for resources held by each other. Operating systems employ strategies such as prevention, avoidance, detection, and recovery. Banker’s algorithm is a canonical approach; understanding its category is fundamental in OS design.
Given Data / Assumptions:
- Processes declare maximum resource needs.
- The system can simulate allocations to test for a safe state.
- A safe sequence exists if every process can finish given available and future releases.
Concept / Approach:
Banker’s algorithm is a deadlock avoidance technique. Before granting a request, the OS checks whether doing so keeps the system in a safe state. If not safe, the request is deferred. Unlike prevention, it does not structurally constrain resource usage; unlike recovery, it does not roll back after deadlock occurs.
Step-by-Step Solution:
Collect processes’ maximum claims.Simulate granting the current request.Run the safety check to see if a completion order exists.Grant only if the resulting state is safe, thereby avoiding deadlock.Verification / Alternative check:
Algorithm descriptions explicitly categorize it under “avoidance” because it anticipates unsafe allocations and refuses them preemptively.
Why Other Options Are Wrong:
- Prevention: Enforces rules (e.g., ordering resources) to make deadlock impossible; not Banker’s approach.
- Recovery: Involves detection and rollback/termination after deadlock.
- Mutual exclusion: A necessary condition for deadlock, not a resolution technique.
- None of the above: Incorrect because avoidance is correct.
Common Pitfalls:
Confusing “safe state” (avoidance) with “deadlock-free state” guaranteed by prevention. Also, assuming real systems always know maximum needs; often they do not, limiting practical use.
Final Answer:
deadlock avoidance