An educational GUI desktop application that simulates process-resource interactions, detects deadlocks, and predicts unsafe states using Banker's Algorithm and Resource Allocation Graphs (RAG).
- Banker's Algorithm Integration: Dynamically calculates Safe/Unsafe states using the Max, Allocation, Need, and Available matrices.
- Interactive Simulation: Step forward and backward through system states to analyze how decisions impact system safety.
- Dynamic Resource Management: Add new processes and resources on the fly.
- Resource Allocation Graph (RAG) Visualization: Real-time generation of bipartite directed graphs using NetworkX and Matplotlib to visualize allocations and requests.
- Deadlock Detection: Advanced graph reduction algorithms detect cycles and definitive deadlocks in multi-instance environments.
- Override Functionality: Bypass Banker's Algorithm to force resource allocations, deliberately creating unsafe states and circular waits to observe deadlock occurrences.
- Language: Python 3
- GUI Framework: PyQt5
- Graph Visualization: NetworkX & Matplotlib (embedded via
FigureCanvasQTAgg) - Architecture: Model-View-Controller (MVC)
- Ensure you have Python 3 installed.
- Install the required dependencies:
pip install PyQt5 numpy networkx matplotlib
- Clone the repository and navigate to the project directory.
- Run the main application:
python main.py
- Left Panel (Controls): Create resources, add processes (with specific max claims), and simulate requests or releases. You can also bypass the Banker's Algorithm here by checking the force allocation box.
- Right Panel (Visualization): Displays the dynamic system status (Safe, Unsafe, Deadlocked, etc.) and visualizes the Resource Allocation Graph. Processes are light blue circles; Resources are light green squares. Solid green arrows denote allocations, and dashed red arrows denote requests.
- Bottom Panel (Matrices): View real-time updates to the Max Claim, Allocation, Need, and Available matrices.
main.py: The central controller that wires the UI and Backend Engine.ui/main_window.py: The programmatic PyQt5 dashboard view.views/canvas.py: The customized Matplotlib Canvas for NetworkX bipartite graph rendering.engine/simulator.py: State manager handling step histories and Banker's logic integration.engine/banker.py: Implementation of Banker's Algorithm for safety sequences.engine/graph_utils.py: RAG construction, cycle detection, and graph-reduction-based deadlock detection.