This C program simulates three classic CPU scheduling algorithms:
- First-Come, First-Served (FCFS)
- Shortest Job First (SJF)
- Round Robin (RR)
It reads process data from an input file and calculates waiting time and turnaround time for each process according to the selected scheduling algorithm.
-
Accepts a CSV input file where each line represents a process:
P0,3 P1,5 ...
Each line contains the process ID and its burst time.
-
Simulates the following algorithms:
-f
for FCFS-s
for SJF-r quantum
for Round Robin with a user-specified time quantum
-
Outputs per-time-unit execution along with each process’s burst left, wait time, and turnaround time.
-
Displays final statistics:
- Per-process wait and turnaround times
- Total average wait and turnaround times
gcc assignment-4.c -o assignment4
./assignment4 -f infile.csv # First-Come, First-Served
./assignment4 -s infile.csv # Shortest Job First
./assignment4 -r 2 infile.csv # Round Robin with quantum 2
T0: P0 - Burst left 3, Wait time 0, Turnaround time 0
T1: P0 - Burst left 2, Wait time 0, Turnaround time 1
...
P0
Waiting time: 0
Turnaround time: 3
Total average waiting time: 2.5
Total average turnaround time: 4.0
- Processes are assumed to arrive at time proportional to their process number (e.g., P0 at T0, P1 at T1).
- Time quantum for RR must be a positive integer.
- Output is printed to standard output.
This project is part of CS 3305A - Operating Systems at Western University. For academic use only.