This project implements and compares five classic CPU scheduling algorithms using clean, efficient, array-based data structures. It simulates how an operating system schedules processes, logs a full execution timeline, and generates detailed performance statistics.
- FCFS — First-Come First-Served
- SJF — Shortest Job First (Non-Preemptive, Min-Heap)
- SRTF — Shortest Remaining Time First (Preemptive, Min-Heap)
- Priority Scheduling — Preemptive (Min-Heap)
- Round Robin — Circular Queue with time slice
- Outputs:
process_stats.csv— final metricsexecution_order.csv— CPU timeline
- Prints final summary:
- total processes
- avg waiting time
- avg turnaround time
- avg completion time
- avg response time
├── main.c
├── scheduler.c
├── scheduler.h
├── input.csv
├── process_stats.csv
└── execution_order.csv
| Algorithm | Data Structure | Reason |
|---|---|---|
| FCFS | FIFO Queue | Maintains arrival order |
| SJF | Min-Heap | Extracts shortest job efficiently |
| SRTF | Min-Heap | Enables preemptive shortest-remaining-time selection |
| Priority | Min-Heap | Quickly selects highest priority |
| Round Robin | Circular Queue | Fair and fast time-slice rotation |
All structures use static arrays, not linked lists.
pid,arrival,burst,priority
1,0,8,2
2,1,4,1
3,2,9,3
4,3,5,2
gcc main.c scheduler.c -o scheduler
./scheduler
Select a scheduling algorithm from the menu.
Contains per-process metrics:
- waiting time
- turnaround time
- response time
- completion time
Contains the CPU timeline:
time,pid,event
0,1,start
4,2,preempted
This project demonstrates how different CPU scheduling algorithms behave under the same workload.
Using array-based queues and heaps ensures efficiency, clarity, and predictable performance.
The simulator produces useful CSV files for analysis and logs a complete execution order for understanding preemption and fairness.