Avoidance grants a request only if the system remains in a safe state: a state in which some order of running all processes to completion exists (a safe sequence).
Banker's algorithm keeps Available (free resources), Max (the most each process may need), Allocation (current holdings) and Need = Max - Allocation. Safety check: set Work = Available; repeatedly find an unfinished process whose Need is at most Work, pretend it finishes and add its Allocation to Work; if all processes can finish, the state is safe.
For a request, check that it is within Need and Available, tentatively grant it, run the safety check, and roll back if the state would be unsafe. It requires knowing maximum needs in advance, so it is rarely used in general-purpose systems.
Loading…