Deadlock Detection

Deadlock Detection Control
System State: SAFE
Processes: 4
Resources: 3
Resource Allocation Graph Ready for Detection
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 xH4: 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
  • hX8: Release resources after hX8
  • xH4: Allow resource xH4
  • 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!