EN
My tools

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.

State
Safe
every process can finish
Safe sequence
<P1, P3, P4, P0, P2>
Available
3 3 2
A B C

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.

Allocation, Max and Need (= Max − Allocation)
ProcessAllocation A B CMax A B CNeed A B C
P00 1 07 5 37 4 3
P12 0 03 2 21 2 2
P23 0 29 0 26 0 0
P32 1 12 2 20 1 1
P40 0 24 3 34 3 1
Safety algorithm steps
StepProcessNeedWork beforeWork afterWhy
1P11 2 23 3 25 3 2Need ≤ Work, so it can finish and release its allocation
2P30 1 15 3 27 4 3Need ≤ Work, so it can finish and release its allocation
3P44 3 17 4 37 4 5Need ≤ Work, so it can finish and release its allocation
4P07 4 37 4 57 5 5Need ≤ Work, so it can finish and release its allocation
5P26 0 07 5 510 5 7Need ≤ Work, so it can finish and release its allocation
My tools →
Advertisement

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

  1. Enter the Allocation matrix, one process per line (P0: 0 1 0).
  2. Enter the Max matrix (or the Request matrix for deadlock detection) in the same order.
  3. Enter the Available vector, or the total instances of each resource.
  4. 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:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). Banker's Algorithm Calculator (Safe Sequence & Deadlock Detection). https://kakao.mobile/tools/banker-s-algorithm-tool/

MLA

“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

Advertisement