A CPU scheduling lab
The problem
Build a program that reads a list of processes and reports how FCFS, SJF, SRTF and round robin schedule them, so that you can choose a scheduler for a given workload with numbers.
Requirements
- Read processes with arrival and burst times, and a quantum for round robin
- Implement FCFS, non-preemptive SJF, SRTF and round robin with the tie-breaking rules written down
- Print each process's completion, turnaround and waiting time and the averages for every algorithm
- Print a Gantt chart as text, and state which algorithm has the lowest average waiting time
Technologies
- C
- Arrays and structs
- Time-unit simulation
- The StepVioz scheduler simulator for checking
Step by step
- Write a struct for a process and read the input into an array.
- Write one function for each algorithm that fills in completion times.
- Compute turnaround and waiting times and print the table for each algorithm.
- Compare the averages on the convoy example (P1 burst 24, P2 and P3 burst 3) and explain what you see.
- Check every result against the simulator in the lessons.
Expected result
A program that prints a table and a Gantt chart for four schedulers on the same workload, and a short comparison.
How it is evaluated
- Every number agrees with a hand calculation and with the simulator
- Ties are broken by one clear rule
- The output of each algorithm is easy to compare
- The comparison names the strengths and weaknesses of each algorithm
Ways to improve it
- Add priority scheduling with aging
- Add HRRN and compare the starvation of long jobs
- Add the cost of a context switch to the model