BANKER’s ALOGORITHM
Banker’s Algorithm is a deadlock avoidance algorithm used in
Operating Systems.
It checks whether allocating requested resources to a process will
keep the system in a safe state or not.
If the system remains safe → resources are allocated
If unsafe → allocation is denied (process must wait)
Data Structures Used
Name Meaning
Free
Available
resources
Maximum
demand of
Max
each
process
Currently
Allocation allocated
resources
Remaining
Need resources
needed
Need = Max – Allocation
How Banker’s Algorithm Works (Steps)
1. When a process requests resources
2. OS checks:
o Request ≤ Need
o Request ≤ Available
3. Temporarily allocate resources
4. Check for safe sequence
5. If safe → grant request
If unsafe → rollback allocation
Safe State
A system is in a safe state if there exists a safe sequence of
processes such that:
Each process can finish using:
Currently available resources
Resources released by previously completed processes
Unsafe State in Operating Systems?
An unsafe state is a system state in which no safe sequence exists
for the execution of processes.
This means:
The OS cannot guarantee that all processes will complete
The system may lead to deadlock, but deadlock has not
occurred yet