CampusFlow
Back to Operating Systems

Operating Systems

Banker's Algorithm Simulator

Simulate Banker's Algorithm to detect safe states, analyze resource allocation and prevent deadlock in Operating Systems.

Safe State Analyzer

Visualize resource allocation and safe sequence execution.

Allocation

Resources currently assigned to each process.

Maximum

Maximum resources required by processes.

Need Matrix

Remaining resources needed for completion.

Safe Sequence

Execution order that avoids deadlock.

Available Resources

System is Safe

A safe sequence exists. No deadlock will occur.

Final Available Resources

10
5
7

Banker's Algorithm Table

ProcessAllocationMaximumNeed
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

Safe Sequence

P1
P3
P4
P0
P2

Step-by-Step Simulation

Step 1

Execute P1

Before

3
3
2

After

5
3
2

Step 2

Execute P3

Before

5
3
2

After

7
4
3

Step 3

Execute P4

Before

7
4
3

After

7
4
5

Step 4

Execute P0

Before

7
4
5

After

7
5
5

Step 5

Execute P2

Before

7
5
5

After

10
5
7

How Banker's Algorithm Works

Banker's Algorithm checks whether granting a resource request keeps the system in a safe state.

The algorithm calculates Allocation, Maximum, Available and Need matrices to determine if all processes can finish successfully.

If a safe sequence exists, the system avoids deadlock and continues execution safely.