A two-layer CPU scheduling simulator built as part of OS coursework at Amrita Vishwa Vidyapeetham. Implements four classic scheduling algorithms in C++, with a live animated GUI frontend in Python.
taskscheduler/
├── task_scheduler.cc # Core scheduling engine in C++ (terminal output)
└── simulator.py # Live animated GUI built on top of the C++ logic
The two files represent two layers of the same project:
task_scheduler.cc— the brain: raw C++ implementation of all four algorithms, runs in terminal, prints Gantt chart as text outputsimulator.py— the face: Python GUI that faithfully mirrors the C++ logic with real-time animation, color-coded Gantt charts, and live metrics
The Python algorithms are written to match the exact behaviour of the C++ backend — same sorting, same tie-breaking, same dependency resolution order.
| Algorithm | Description |
|---|---|
| FCFS | First Come First Served — sorted by arrival time, first eligible task runs |
| SJF | Shortest Job First — picks the task with minimum burst time among eligible |
| Round Robin | Time-sliced with configurable quantum, re-enqueues preempted tasks |
| Priority | Picks task with lowest priority number among eligible |
All four algorithms support:
- DAG dependencies — a task can declare
depends_on: [T1, T2]and will be blocked until those finish - Deadlines — each task has a deadline; missed tasks are flagged in the results
- Slack time — computed as
deadline - finish_time
Requirements: Python 3.x (tkinter is included in standard library)
python simulator.py- Enter tasks — name, submit time, duration, priority, deadline, and optional dependencies (e.g.
T1,T2) - Select an algorithm and optionally set quantum (for Round Robin)
- Adjust animation speed with the slider
- Hit RUN — watch the Gantt chart animate live
g++ -o scheduler task_scheduler.cc
./schedulerOutputs a text-based Gantt chart and per-task metrics (waiting time, completion time, slack) to the terminal.
- Live Gantt chart — color-coded blocks scroll in real time as the scheduler runs
- Deadline markers — red dashed lines show each task's deadline on the Gantt
- Per-task progress bars — show WAITING / BLOCKED / PAUSED / DONE states
- BLOCKED state — tasks waiting for dependencies are highlighted in purple
- Results table — updates as tasks complete; missed deadlines highlighted in red
- Live stats — avg waiting time, avg completion time, makespan, deadline hit rate, avg slack
- Pause / Resume / Stop controls
- Adjustable speed — from 0.2x to 5x
This project directly maps to core OS topics:
- CPU scheduling algorithms (GATE CSE syllabus)
- DAG-based task dependency graphs
- Preemption and context switching (Round Robin)
- Deadline scheduling and slack time
- NachOS thread scheduling internals
- C++ — core algorithm implementation
- Python 3 — GUI and animation
- Tkinter — UI framework (standard library, no installs needed)
- Threading — animation runs on a separate thread to keep UI responsive
Anwi — BTech CSE, Amrita Vishwa Vidyapeetham, Bengaluru
GitHub: @Anwiii