OS Deadlock Detection

OS Deadlock Detection Visually

Interactive Deadlock Detection with visual animations. Learn deadlock conditions, resource allocation graphs, and detection algorithms with step-by-step visualization.

Deadlock Detection Resource Allocation Graph Wait-for Graph Process Monitoring Deadlock Identification CPU / Resource Management Visual Simulation
Simulation Controls
Status:
System initialized and ready
Deadlock Detection Control
System State: SAFE
Processes: 4
Resources: 3
Resource Allocation Graph Ready for Detection
Available Resources
R1
3
R2
3
R3
2
Allocation Matrix
Process R1 R2 R3
P1010
P2200
P3302
P4211
Request Matrix
Process R1 R2 R3
P1202
P2101
P3001
P4002
Detection Results --
No Deadlock Detected - System is in Safe State
Select an algorithm and click Detect to begin deadlock detection

About Deadlock

A deadlock occurs when processes are blocked forever, waiting for resources held by each other.

  • Mutual Exclusion: Resources cannot be shared
  • Hold and Wait: Process holds resources while waiting
  • No Preemption: Resources cannot be forcibly taken
  • Circular Wait: Circular chain of waiting processes

Detection Algorithms

Resource Allocation Graph:

1. Create RAG with processes and resources 2. Draw allocation and request edges 3. Check for cycles in the graph 4. If cycle exists → Deadlock detected

Banker's Algorithm:

1. Check if system is in safe state 2. Find process that cAn complete 3. Release its resources 4. Repeat until all processes complete 5. If stuck → Deadlock detected

Detection Methods

Resource Allocation Graph:

  • Visual representation of resource allocation
  • Cycle detection indicates deadlock
  • Works for single instance resources

Wait-For Graph:

  • Simplified version of RAG
  • Shows only process dependencies
  • Easier cycle detection

Banker's Algorithm:

  • Works with multiple resource instances
  • Checks for safe state existence
  • More comprehensive detection

Prevention Strategies

  • Resource Ordering: Always request resources in same order
  • Timeout: Release resources after timeout
  • Preemption: Allow resource preemption
  • Avoidance: Use Banker's algorithm for allocation

How to Use

  1. Select a detection algorithm from dropdown
  2. Click Detect to run deadlock detection
  3. Use Step to see algorithm execution step-by-step
  4. Try Demo to see different deadlock scenarios
  5. Click Reset to start with new configuration

Watch the Resource Allocation Graph and matrices to understand how deadlock detection works!

Simulation Event Log
Deadlock Scenarios
Real-World Examples
Scenario Statistics

Allocation Matrix

Request Matrix

Available Resources