A C++ implementation of various CPU scheduling algorithms for Operating Systems coursework.
This project simulates and compares four different CPU scheduling algorithms:
- FCFS (First Come First Served)
- SJN (Shortest Job Next)
- SRT (Shortest Remaining Time)
- Round Robin (Time Quantum = 4ms)
- Implements four classic CPU scheduling algorithms
- Calculates and displays completion time, turnaround time, and waiting time for each job
- Provides detailed results for each algorithm
- Includes a comparison table showing average metrics across all algorithms
- Clean, formatted output with professional presentation
The simulator uses the following test data:
- Job A: Arrival Time = 0ms, CPU Cycle = 16ms
- Job B: Arrival Time = 3ms, CPU Cycle = 2ms
- Job C: Arrival Time = 5ms, CPU Cycle = 11ms
- Job D: Arrival Time = 9ms, CPU Cycle = 6ms
- Job E: Arrival Time = 10ms, CPU Cycle = 1ms
- Job F: Arrival Time = 12ms, CPU Cycle = 9ms
- Job G: Arrival Time = 14ms, CPU Cycle = 4ms
- Job H: Arrival Time = 16ms, CPU Cycle = 14ms
- Job I: Arrival Time = 17ms, CPU Cycle = 1ms
- Job J: Arrival Time = 19ms, CPU Cycle = 8ms
To compile the project, use the following command:
g++ -o scheduler main.cpp Job.cpp FCFS.cpp SJN.cpp SRT.cpp RoundRobin.cpp OutputFormatter.cpp SchedulerBase.cppAfter compilation, run the executable:
./scheduler.exeThe program will display:
- Individual results for each scheduling algorithm
- Detailed metrics for each job (completion time, turnaround time, waiting time)
- Average waiting time and turnaround time for each algorithm
- A comparison table showing average metrics across all algorithms
main.cpp- Main program entry pointJob.h/cpp- Job class definition and implementationSchedulerBase.h/cpp- Base scheduler classFCFS.h/cpp- First Come First Served implementationSJN.h/cpp- Shortest Job Next implementationSRT.h/cpp- Shortest Remaining Time implementationRoundRobin.h/cpp- Round Robin implementationOutputFormatter.h/cpp- Output formatting utilities
- Course: CS433 Operating Systems
- Task: Task 3 - CPU Scheduling Algorithms
- Time Quantum: 4ms (for Round Robin)
- Context Switching Time: 0ms
- C++ compiler with C++11 support or later
- Standard C++ libraries