Resource Allocation Graph
Ready for Detection
Available Resources
R1
3
R2
3
R3
2
Allocation Matrix
| Process | R1 | R2 | R3 |
|---|---|---|---|
| P1 | 0 | 1 | 0 |
| P2 | 2 | 0 | 0 |
| P3 | 3 | 0 | 2 |
| P4 | 2 | 1 | 1 |
Request Matrix
| Process | R1 | R2 | R3 |
|---|---|---|---|
| P1 | 2 | 0 | 2 |
| P2 | 1 | 0 | 1 |
| P3 | 0 | 0 | 1 |
| P4 | 0 | 0 | 2 |
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 runDetection 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
- Select a detection algorithm from dropdown
- Click Detect to run deadlock detection
- Use Step to see algorithm execution step-by-step
- Try Demo to see different deadlock scenarios
- Click Reset to start with new configuration
Watch the Resource Allocation Graph and matrices to understand how deadlock detection works!