A comprehensive web-based simulation platform for understanding and visualizing distributed deadlock detection, prevention, and avoidance algorithms.
-
Three Deadlock Modes:
- 🔍 Detection: Monitor and detect circular wait conditions using cycle detection
- 🛡️ Prevention: Prevent deadlocks using resource ordering
- 🎯 Avoidance: Use Banker's Algorithm to maintain safe states
-
Network Simulation:
- Single node pair simulation
- Multi-node network simulation over WiFi/LAN
- Real-time connection status monitoring
-
Visualization:
- Interactive resource allocation graph
- Process state tracking (ready, running, waiting, terminated)
- Resource utilization charts
- Live statistics dashboard
-
Algorithms Implemented:
- DFS-based cycle detection
- Resource ordering prevention
- Banker's Algorithm for avoidance
- Process and resource management
- Python 3.8+
- Windows, Linux, or macOS
cd d:\project\os_streamlitpip install -r requirements.txtOr manually:
pip install streamlit==1.28.1 pandas==2.1.3 plotly==5.18.0 numpy==1.24.3 python-dotenv==1.0.0run.batThe app will open at http://localhost:8503
streamlit run app.py- Select connection mode (Single Node Pair or Multiple Nodes)
- Enter node ID, IP address, and port
- Set number of processes and resources
- Click "Start Simulation"
-
Resource Operations:
- Request Resource: Send resource request to peer
- Release Resource: Release held resources
-
Auto-Pilot: Automatically step through simulation
-
Pause/Resume: Control simulation flow
-
Mode Selection: Switch between Detection, Prevention, and Avoidance
-
Monitoring:
- View resource allocation graph
- Track statistics (requests, grants, denials, deadlocks, etc.)
- Monitor connection status
- Review activity logs
On Each System:
-
Find your IP address:
- Windows:
ipconfig→ Look for IPv4 Address (e.g., 192.168.1.100) - Linux/Mac:
ifconfigorip addr
- Windows:
-
Ensure all systems are on the same WiFi network
-
Configure in the app:
- Enter your IP address (not 127.0.0.1)
- Choose unique ports for each system
- Set total number of systems
-
Allow Python through firewall if prompted
os_streamlit/
├── app.py # Main Streamlit application
├── coordinator.py # System coordination and process management
├── detection.py # Deadlock detection algorithm (DFS cycle detection)
├── prevention.py # Deadlock prevention (resource ordering)
├── banker.py # Deadlock avoidance (Banker's Algorithm)
├── process.py # Process class and state management
├── resource.py # Resource allocation and tracking
├── requirements.txt # Python dependencies
├── run.bat # Windows startup script
├── setup_firewall.ps1 # Windows firewall configuration
└── README.md # This file
- Builds a wait-for graph showing dependencies between processes
- Uses Depth-First Search (DFS) to detect cycles
- Initiates recovery by terminating a process in the cycle
- Suitable for systems that can tolerate deadlocks
- Enforces resource ordering constraint
- Processes must request resources in increasing order
- Prevents circular wait condition
- Lower resource utilization but guarantees deadlock-free operation
- Implements Banker's Algorithm
- Maintains system in safe states
- Checks if resource allocation leaves system in safe state
- Maximum process demand must be declared in advance
- Requests: Total resource requests made
- Grants: Successfully allocated resources
- Denials: Requests denied due to prevention rules
- Deadlocks: Circular waits detected
- Recoveries: Deadlock recovery operations
- Prevented: Requests blocked by prevention algorithm
- Avoided: Requests handled by avoidance algorithm
- Releases: Resource releases completed
- Check if peer node is running on correct IP and port
- Verify firewall isn't blocking the ports
- Ensure both systems are on same network (for WiFi setup)
- Values are stored in session state
- Settings are applied when "Start Simulation" is clicked
- Adjust values before starting simulation
- Test connectivity: Use "Test Network" button in configuration
- Check local IP addresses with
ipconfig(Windows) orifconfig(Linux/Mac) - Verify firewall rules allow Python
- Ensure ports are in valid range (1024-65535)
- Check Python version:
python --version(should be 3.8+) - Verify all dependencies installed:
pip install -r requirements.txt - Check logs for error messages
- Optimal simulation with 4-6 processes
- 2-3 processes for simple scenarios
- 8-10 processes for stress testing
- Graph rendering may slow down with many processes
Educational project for deadlock algorithm understanding
This project demonstrates:
- Operating system concepts (deadlock handling)
- Distributed systems principles
- Algorithm visualization
- Real-time system monitoring
- Multi-threaded simulation
For issues or questions:
- Check the Troubleshooting section
- Review algorithm documentation in source code
- Enable debug logging by modifying app.py
Last Updated: November 22, 2025