Operating Systems
Deadlock & Banker's Algorithm
Learn deadlock detection, safe state analysis and resource allocation using Banker's Algorithm with interactive simulation.
Deadlock Simulator
Analyze process execution and detect safe or unsafe states.
Deadlock
A situation where processes wait forever for resources.
Safe State
System can allocate resources safely without deadlock.
Banker's Algorithm
Prevents unsafe resource allocation dynamically.
Resource Allocation
Manages CPU, memory and device resource distribution.
Available Resources
Safe State
The system can execute processes safely without entering deadlock.
Process Allocation Table
| Process | Allocation | Maximum | Need |
|---|---|---|---|
| P0 | 0 , 1 , 0 | 7 , 5 , 3 | 7 , 4 , 3 |
| P1 | 2 , 0 , 0 | 3 , 2 , 2 | 1 , 2 , 2 |
| P2 | 3 , 0 , 2 | 9 , 0 , 2 | 6 , 0 , 0 |
| P3 | 2 , 1 , 1 | 2 , 2 , 2 | 0 , 1 , 1 |
| P4 | 0 , 0 , 2 | 4 , 3 , 3 | 4 , 3 , 1 |
Safe Sequence
How Deadlock Happens
Deadlock occurs when multiple processes hold resources while waiting for other resources locked by other processes.
Banker's Algorithm checks whether resource allocation keeps the system in a safe state before granting requests.
If a safe sequence exists, processes can complete execution without deadlock.