BBobop Deadlock

index tools
Resource Allocation Graph
Banker's Algorithm

Setup

Edges

Click Init to begin
Resource Allocation Graph
Process Resource Assigned Request (wait)
Detection Result
Configure edges and click Detect Deadlock to run cycle detection on the wait-for graph.
How It Works
Resource Allocation Graph (RAG)

A directed graph where:
- Circles = processes (P0, P1, ...)
- Squares = resources (R0, R1, ...)
- Green arrow R → P = resource assigned to process
- Red arrow P → R = process is waiting for resource

Deadlock exists if and only if there is a cycle in the wait-for graph. We detect this using DFS with coloring (white/gray/black). A back edge (to a gray node) indicates a cycle.

Conditions for deadlock:
1. Mutual exclusion
2. Hold and wait
3. No preemption
4. Circular wait (the cycle)

Setup

Available Resources
Allocation Matrix
Max Matrix
Need Matrix (Max - Allocation)
Safety Check Result
Fill in the matrices and click Run Banker's to check if the state is safe.
Algorithm Steps
How It Works
Banker's Algorithm (Dijkstra, 1965)

Determines if a resource allocation state is safe — meaning there exists at least one sequence in which all processes can finish without deadlock.

Need[i] = Max[i] - Allocation[i]

Safety algorithm:
1. Let Work = Available, Finish[i] = false
2. Find process i where Finish[i]=false AND Need[i] ≤ Work
3. Work = Work + Allocation[i], Finish[i] = true
4. Repeat until done
5. If all Finish[i]=true, state is SAFE

A safe sequence is the order in which processes can complete.