Scheduling and Fairness Section 7 Scheduling and Fairness March 3rd, 2017 Taught by Joshua Don
Scheduling Scheduling: The process by which the kernel selects the next thread/process to run Fairness: A measure of how equitably the kernel allocates system resources (ie. CPU usage to run each process)
First come, first serve FIFO; run in the order of arrival Processes arrive: P2, P1, P3 We run: P2, P1, P3
Round robin Each process gets a short amount of time to run, before it is pushed to the back of the queue Cycle through all processes Processes arrive: P2, P1, P3 We run: P2, P1, P3, P2, P1, P3, P2, P1, P3, ….
Simple priority scheduling Run whatever process has the highest priority If using preemption, can preempt the currently running process if a higher priority process arrives Processes arrive: P2 – 5, P1 - 10 We start running: P1 P3 – 15 arrives Overall order will look like: P1, P3, P1, P2
Shortest remaining time first Run whatever process has the least amount of time left to completion Processes arrive: P2 - 4 ticks, P1 – 3 ticks, P3 – 5 ticks We run: P1, P2, P3
Other scheduling ideas Run a random process at each interval Decrease/increase priority based on how long a process has been waiting to get CPU time Choose processes randomly, but with probability proportional to priority Choose process with earliest deadline Round-robin among the highest priority processes (ie. MLFQS in proj1)
Scheduling overview There are many other scheduling algorithms, many are much more complicated. Each algorithm has pros and cons; need to consider how they handle mixture of different processes – different run times, priorities, etc. Some are harder to implement Some require more overhead to figure out which process to schedule Each algorithm tries to optimize its own definition of fairness