Prev: scheduling-introduction Next: scheduling-proportional-share
Since we no longer know how long jobs will last, let’s optimize for turnaround time and response time (efficiency and fairness).
MLFQ has a number of distinct queues, which are assigned a different priority level.
There are two basic rules:
They key to MLFQ is how it sets priority. If a job relinquishes the CPU while waiting for input from the keyboard, MLFQ keeps its priority high. However, if a job uses CPU intensively for long periods of time, MLFQ will reduce its priority. Thus, it uses history to predict future behavior.
Imagine if there’s a long running job A, where B, a short running job comes in. Well, as soon as B comes in, it will run on the next time slice, and then A would run. This is good for turnaround time and response time.
The key here is that MLFQ guesses that jobs are short running, and penalizes it the longer it runs (treats it more like a batch job).
If a job runs I/O before its time slice is up, it relinquishes control to the CPU and gets to stay at the same level.
To avoid starvation, we can periodically boost the priority of all the jobs in the system, by making a new rule.
This fixes the starvation problem, at the cost of requiring a voodoo constant. What should we set S to? It could be configurable.
To stop gaming of the system, we can keep track of how much CPU time each process has used. Rewriting rule 4:
A few other issues arise with MLFQ. How many queues should there be? How long should the time slice be? How long should the priority bump be?
Maybe we can use some sort of a decay to penalize certain actions.
Prev: scheduling-introduction Next: scheduling-proportional-share