An interactive, modern CPU Scheduling Algorithm Simulator built with Streamlit, featuring real-time visualizations, comprehensive performance metrics, and AI-powered explanations using Google's Gemini 1.5.
- ๐ Gantt Chart Visualization - Interactive timeline showing process execution with color-coded blocks
- ๐ฌ Algorithm Comparison Mode - Run and compare all algorithms simultaneously with side-by-side analysis
- ๐พ Export Results (CSV/PDF) - Download simulation results in multiple formats for reporting
- ๐ฌ Step-by-Step Animation - Animated execution timeline with play/pause controls
- ๐ Predefined Scenarios - Quick-start templates (Gaming, Web Server, Batch Processing, Real-Time, Mixed)
- ๐ Real-Time Metrics Dashboard - Live CPU utilization, throughput, and performance indicators
- ๐ Process Queue Visualization - Visual representation of ready queue states
- ๐ Interactive Charts - Pie charts, line graphs, and bar charts for data analysis
- ๐ค Gemini AI Chatbot - AI-powered advisor for algorithm explanations and recommendations
- ๐๏ธ Performance Analysis Metrics - Comprehensive metrics including fairness index, response time, and efficiency
- Modern Dark Theme with gradient accents and smooth animations
- Responsive Layout optimized for all screen sizes
- Custom CSS Styling with hover effects and transitions
- Theme Toggle (Dark/Light mode support)
- Professional UI with metric cards and data visualizations
| Algorithm | Description | Best For |
|---|---|---|
| FCFS | First Come First Serve | Simple queue-based systems |
| SJF | Shortest Job First | Minimizing waiting time |
| Priority | Priority-based scheduling | Critical process handling |
| Round Robin | Time-sliced scheduling | Fair CPU time distribution |
- Python 3.8 or higher
- pip package manager
git clone https://github.com/yourusername/cpu-scheduling-simulator.git
cd cpu-scheduling-simulator# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtstreamlit>=1.28.0
pandas>=2.0.0
matplotlib>=3.7.0
plotly>=5.15.0
google-generativeai>=0.3.0
fpdf2>=2.7.0
numpy>=1.24.0
Pillow>=10.0.0
streamlit run app.pyThe application will open in your default browser at http://localhost:8501
-
Choose a Scenario (Optional)
- Select from predefined scenarios in the sidebar
- Or choose "Custom" to enter your own process data
-
Configure Processes
- Set number of processes (1-10)
- Enter Arrival Time (AT), Burst Time (BT), and Priority for each process
- View process summary in the sidebar
-
Select Algorithm
- Choose from FCFS, SJF, Priority, or Round Robin
- For Round Robin, set the time quantum
-
Run Simulation
- Click "
โถ๏ธ Run Simulation" for single algorithm - Click "๐ฌ Compare All Algorithms" to compare all four
- Click "
-
Explore Results
- Overview Tab: Basic results and statistics
- Gantt Chart Tab: Visual execution timeline
- Metrics Dashboard: Comprehensive performance metrics
- Detailed Analysis: Insights and interactive charts
- Export Tab: Download results as CSV or PDF
-
Use AI Advisor
- Switch to "๐ค AI Advisor" tab
- Ask questions about algorithms
- Get performance analysis and recommendations
- Use quick action buttons for instant explanations
- Waiting Time: Time spent waiting in ready queue
- Turnaround Time: Total time from arrival to completion
- Response Time: Time from arrival to first execution
- CPU Utilization: Percentage of time CPU is busy
- Throughput: Processes completed per unit time
- Fairness Index: Measure of waiting time distribution (1.0 = perfectly fair)
- Efficiency Ratio: Ratio of useful work to total time
The simulator includes a built-in AI advisor powered by Google's Gemini 1.5 that can:
- Explain Algorithms: Detailed explanations of FCFS, SJF, Priority, and Round Robin
- Analyze Results: Interpret your simulation metrics and provide insights
- Give Recommendations: Suggest the best algorithm for your workload
- Answer Questions: General OS and scheduling questions
- Run a simulation first (provides context)
- Go to "๐ค AI Advisor" tab
- Type your question or use quick action buttons
- Get AI-powered responses with clear formatting
cpu-scheduling-simulator/
โโโ app.py # Main application entry point
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ TODO.md # Development checklist
โโโ assets/
โ โโโ style.css # Custom CSS styling
โโโ core/
โ โโโ __init__.py
โ โโโ algorithms.py # Scheduling algorithms (FCFS, SJF, etc.)
โ โโโ gantt.py # Gantt chart generation
โ โโโ metrics.py # Performance metrics calculation
โโโ ui/
โ โโโ __init__.py
โ โโโ layout.py # Page layout and styling
โ โโโ inputs.py # User input handling
โ โโโ results.py # Results display and export
โ โโโ chatbot.py # Gemini AI integration
โโโ report/
โ โโโ manual_computation.md
โ โโโ os_analysis.md
โ โโโ screenshots/
โโโ utils/ # Utility functions
This simulator is perfect for:
- Students learning operating systems concepts
- Instructors teaching CPU scheduling
- Developers understanding algorithm behavior
- Researchers analyzing scheduling performance
- Start with predefined scenarios to understand different workloads
- Experiment with custom process configurations
- Compare algorithms to see their strengths and weaknesses
- Use the AI advisor to deepen understanding
- Export results for assignments or reports
The Gemini API key is pre-configured in ui/chatbot.py:
GEMINI_API_KEY = "YOUR_API_KEY"To use your own API key:
- Get a key from Google AI Studio
- Replace the key in
ui/chatbot.py - Restart the application
- Edit
assets/style.cssto change colors and styling - Modify
ui/layout.pyto adjust page structure - Update
core/algorithms.pyto add new scheduling algorithms
Module Not Found Error
pip install -r requirements.txtStreamlit Not Running
# Check if streamlit is installed
pip show streamlit
# Reinstall if needed
pip install --upgrade streamlitGemini API Errors
- Check internet connection
- Verify API key is valid
- Check API quota limits
Port Already in Use
streamlit run app.py --server.port 8502Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add some AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Streamlit for the amazing web app framework
- Google Gemini for AI capabilities
- Plotly for interactive visualizations
- FPDF for PDF export functionality
- Arron Kian Parejas (App Developer)
- Graciella Mhervie Jimenez (Project Manager)
- Jenica Sarah Tongol (Documentation/QA)
- Jian kalel Marquez (Unit Testing/Documentation)
For questions or suggestions, please open an issue on GitHub or contact the maintainer.
Happy Scheduling! ๐ฅ๏ธโก
Built with โค๏ธ using Streamlit and Gemini 3.0
