The Banker's Algorithm is a resource allocation and deadlock avoidance algorithm used in operating systems. It was developed by Edsger Dijkstra and is named "Banker's algorithm" because it simulates how a bank manages its money - never allocating more than it has and always maintaining a safe state.
A state is safe if the system can allocate resources to each process in some order without causing a deadlock.
A sequence of processes that can be executed completely without causing deadlock.
Different categories of resources (A, B, C, etc.) that processes need to complete their execution.
The maximum number of resources a process might need (also called Max).
| Variable | Description |
|---|---|
| Available | Vector of available resources of each type |
| Max | Matrix defining maximum demand of each process |
| Allocation | Matrix defining resources currently allocated to each process |
| Need | Matrix defining remaining resource needs of each process (Max - Allocation) |
Set up the Work vector = Available and Finish[i] = false for all processes.
Find a process Pi such that:
If no such process exists, go to step 4.
Work = Work + Allocationi
Finish[i] = true
Go back to step 2.
If Finish[i] = true for all processes, the system is in a safe state.
The Banker's Algorithm is used in various resource management systems: