A console-based C++ project that simulates key CPU scheduling algorithms:
- FCFS (First-Come, First-Served)
- SJF (Shortest Job First)
- Round Robin (with Time Quantum 4)
- Priority Scheduling
Built from scratch using core C++ concepts like vectors, sorting, conditionals, and process struct modeling, this tool visualizes execution order, timing metrics, and Gantt charts — mimicking how a real CPU scheduler functions.

- ⏳ Interactive input for process details
- 📊 Gantt chart-like visual display
- 🧮 Calculates: Completion Time, Turnaround Time, Waiting Time
- 🔁 Round Robin with fixed time quantum (4 units)
- 📋 Priority support (lower number = higher priority)
Logic: Sort processes by arrival time and execute one after another.
sort(processes.begin(), processes.end(), compareByArrivalTime);Example:
| PID | Arrival | Burst |
|---|---|---|
| 1 | 0 | 4 |
| 2 | 1 | 3 |
🕐 Gantt Chart: | P1 (0–4) | P2 (4–7) |
Logic: At each time, pick the process with the smallest burst that has arrived.
if (p.arrivalTime <= currentTime && p.burstTime < minBurst)Logic: Use a queue; each process gets 4 units in turn until done.
queue<Process> q;
remainingBurst[p.pid] = p.burstTime;Logic: Execute by priority, resolve ties using arrival time.
sort(processes.begin(), processes.end(), [](a, b) {
return a.priority < b.priority || (a.priority == b.priority && a.arrivalTime < b.arrivalTime);
});Now executing Process P2 at time 0
Processing...
Process P2 finished at time 3
-----------------------------------------🕐 Final Table:
| PID | Arrival | Burst | Arrival | Burst | Burst |
|---|---|---|---|---|---|
| 1 | 0 | 4 | 4 | 4 | 0 |
g++ main.cpp -o CPUSchedPlusPlus
./CPUSchedPlusPlusOr compile all .cpp files together, depending on your setup.
├── main.cpp
├── scheduler.cpp
├── utils.cpp
├── headers/
│ ├── process.h
│ ├── fcfs.h
│ ├── sjf.h
│ ├── rr.h
│ ├── priority.h
│ ├── scheduler.h
│ └── utils.h
├── algorithms/
│ ├── fcfs.cpp
│ ├── sjf.cpp
│ ├── rr.cpp
│ └── priority.cpp
└── README.md
As part of core Computer Science learning, this project strengthens understanding of:
- OS scheduling theory
- Time management of processes
- Simulation of real CPU-like behaviour
- C++ data structures and logic building
- Add Preemptive SJF or Multilevel Queues
- Export table as CSV
- GUI-based interface (maybe in Qt or web)
Neha Ghariyal
📫 GitHub | 📧 nehaghariyal19@gmail.com