Banker's Algorithm Calculator (Safe Sequence & Deadlock Detection)
Run the Banker's algorithm: Need matrix, safety check with a step table and safe sequence, resource-request check for a process, or deadlock detection.
A state can have several safe sequences; this one follows the chosen search order.
Safe means some order lets every process get its maximum and finish. Unsafe does not mean deadlocked yet — only that a deadlock can no longer be ruled out.
| Process | Allocation A B C | Max A B C | Need A B C |
|---|---|---|---|
| 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 |
| Step | Process | Need | Work before | Work after | Why |
|---|---|---|---|---|---|
| 1 | P1 | 1 2 2 | 3 3 2 | 5 3 2 | Need ≤ Work, so it can finish and release its allocation |
| 2 | P3 | 0 1 1 | 5 3 2 | 7 4 3 | Need ≤ Work, so it can finish and release its allocation |
| 3 | P4 | 4 3 1 | 7 4 3 | 7 4 5 | Need ≤ Work, so it can finish and release its allocation |
| 4 | P0 | 7 4 3 | 7 4 5 | 7 5 5 | Need ≤ Work, so it can finish and release its allocation |
| 5 | P2 | 6 0 0 | 7 5 5 | 10 5 7 | Need ≤ Work, so it can finish and release its allocation |
The Banker's algorithm decides whether a system with several resource types is in a safe state — whether there is an order in which every process can obtain what it may still need and finish — and whether a new request can be granted without losing that safety. This calculator builds the Need matrix, runs the safety algorithm step by step with the Work vector, checks a resource request, and also runs the related deadlock-detection algorithm on a Request matrix.
How to use this tool
- Enter the Allocation matrix, one process per line (P0: 0 1 0).
- Enter the Max matrix (or the Request matrix for deadlock detection) in the same order.
- Enter the Available vector, or the total instances of each resource.
- Optionally enter a request such as P1 1 0 2 and read whether it is granted.
Formula
Need = Max − Allocation · Work = Available; repeat: find Pᵢ with Need ≤ Work, then Work = Work + Allocationᵢ · safe if every process finishes
A request from Pᵢ is an error if it exceeds Need, must wait if it exceeds Available, and otherwise is granted only if the state after pretending to allocate it is still safe. Deadlock detection uses the current Request instead of Need and marks processes that hold nothing as finished from the start; those that never finish are deadlocked. Several safe sequences may exist — the search order option reproduces the two common ways of tracing it.
Example
The sample is the textbook example of Silberschatz's Operating System Concepts: 5 processes, resources A, B, C, Available (3, 3, 2). Need is P0 (7,4,3), P1 (1,2,2), P2 (6,0,0), P3 (0,1,1), P4 (4,3,1). P1 can finish first (Work becomes 5 3 2), then P3 (7 4 3), P4 (7 4 5), P0 (7 5 5) and P2 (10 5 7), so the state is safe with the sequence <P1, P3, P4, P0, P2>. The request (1, 0, 2) by P1 is granted.
Frequently asked questions
Is an unsafe state a deadlock?
No. Unsafe means the system can no longer guarantee that all processes finish; a deadlock may or may not happen. A deadlock is a state where some processes are actually waiting on each other forever.
Why is my safe sequence different from the book?
A safe state often has several safe sequences. Books trace the search in slightly different ways; switch the search order to match yours. Any sequence the algorithm finds is valid.
What is the difference between Max and Request?
Max is the most a process may ever claim (used to avoid deadlock in advance). Request is what a process is waiting for right now (used to detect a deadlock that has happened).
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/banker-s-algorithm-tool/
Cite or embed this tool
kakaoCalc. (2026, November 8). Banker's Algorithm Calculator (Safe Sequence & Deadlock Detection). https://kakao.mobile/tools/banker-s-algorithm-tool/
“Banker's Algorithm Calculator (Safe Sequence & Deadlock Detection).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/banker-s-algorithm-tool/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms