What is the purpose of banker’s algorithm?

2017

What is the purpose of banker’s algorithm?

Answer: D. None of theseConcept. An operating system can deal with deadlock in four distinct ways, and standard OS theory keeps them separate. Prevention designs the request protocol…

  1. A.

    To detect deadlock

  2. B.

    To prevent deadlock

  3. C.

    To solve deadlock

  4. D.

    None of these

Attempted by 360 students.

Show answer & explanation

Correct answer: D

Concept. An operating system can deal with deadlock in four distinct ways, and standard OS theory keeps them separate. Prevention designs the request protocol so that one of the four Coffman conditions — mutual exclusion, hold-and-wait, no preemption, circular wait — can never hold. Avoidance leaves those conditions intact and instead examines each request at run time, granting it only if the resulting state is still safe, that is, only if some ordering of the processes lets every one of them finish with the resources that remain. Detection lets a deadlock form and then searches the allocation state for a circular wait, and recovery breaks an identified deadlock by aborting or preempting processes.

Application. The Banker's algorithm implements the second of these. Every process declares its maximum claim in advance, and on each resource request the algorithm proceeds as follows:

  1. Compare the request with the process's remaining Need and with the currently Available units; if it exceeds either, the process waits.

  2. Tentatively allocate the requested units and recompute the Available, Allocation and Need matrices for that hypothetical state.

  3. Run the safety algorithm on that state: repeatedly find a process whose Need is less than or equal to Available, mark it as able to finish, and add its Allocation back to Available.

  4. If every process can be marked in some order, the state is safe and the allocation is committed; if no such order exists, the tentative allocation is undone and the requester blocks.

Nothing in that procedure negates a Coffman condition, searches for a cycle that has already formed, or aborts a running process. The algorithm simply refuses any grant that would move the system out of a safe state, which is precisely the definition of deadlock avoidance.

Cross-check. Comparing that behaviour with each purpose offered:

Offered purpose

What that strategy does

Banker's algorithm?

To detect deadlock

Searches the allocation state for a circular wait after one may already exist

No — it runs before each grant and never reports an existing cycle

To prevent deadlock

Statically negates one of the four Coffman conditions by protocol design

No — all four conditions remain possible; only unsafe grants are refused

To solve deadlock

Terminates or preempts processes to break a deadlock that already exists

No — it never aborts or rolls back a process

None of these

Catch-all for a purpose outside the three above

Yes — the purpose is deadlock avoidance, which is not listed

Result. The purpose of the Banker's algorithm is deadlock avoidance, and none of the three named purposes is avoidance, so “None of these” is the choice that holds. Some texts do use “prevention” loosely for any technique that stops a deadlock from arising; in the standard four-way classification used by this syllabus, and with an explicit “None of these” option on offer, avoidance and prevention remain separate categories, so that loose reading does not apply here.

Explore the full course: Btsc Lab Assistant

Loading lesson…