In an operating system, Banker's algorithm is used to:
2025
In an operating system, Banker's algorithm is used to:
Answer: B. prevent deadlock — Concept: Deadlock prevention and deadlock avoidance are distinct textbook categories. Prevention structurally removes at least one necessary condition for…
- A.
deadlock recovery
- B.
prevent deadlock
- C.
deadlock removal
- D.
none of these choices
Attempted by 453 students.
Show answer & explanation
Correct answer: B
Concept: Deadlock prevention and deadlock avoidance are distinct textbook categories. Prevention structurally removes at least one necessary condition for deadlock, whereas avoidance tests a proposed allocation and permits it only when a safe completion sequence still exists. The Banker's algorithm belongs to the avoidance category.
Application: For each resource request, the algorithm performs a safety test before committing the allocation:
Treat the requested resources as provisionally allocated and update the available and remaining-need values.
Search for an order in which every process can obtain its remaining need, finish, and release its resources.
Grant the request only when such a safe sequence exists; otherwise defer the request.
Concrete example: suppose one resource type has 10 instances. P1 holds 5 and may need 7 in total, P2 holds 2 and may need 6, so 3 instances are available.
For a request of 2 by P1, provisional availability becomes 1 and P1 has no remaining need.
P1 can finish and release its 7 instances, raising availability to 8; P2 can then obtain its remaining 4 and finish. This is a safe sequence.
For a request of 3 by P2 instead, provisional availability becomes 0 while P1 still needs 2 and P2 still needs 1. No process can finish, so that allocation is unsafe and must be deferred.
Cross-check / contrast: The alternatives describe different timing or a set-level fallback:
“deadlock recovery” acts after a deadlock has formed.
“deadlock removal” is a nonstandard label for clearing an existing deadlock and is also reactive.
“none of these choices” applies only when no substantive offered description fits.
Result: Among the offered choices, “prevent deadlock” is the accepted answer: it is the only offered description that acts before allocation, which is exactly where the safety test operates. Technically the Banker’s algorithm reaches that outcome through deadlock avoidance rather than through the distinct textbook strategy called deadlock prevention; that gap is one of labelling, not a missing description, so the set-level fallback is not the intended choice, and the official key for this paper carries the same answer.