Attempt #1: How To Change Priority

Let's discover how the MLFQ changes the ​priority​ of a process based on the time it takes and the resources it uses.

We now must decide how MLFQ is going to change the priority level of a job (and thus which queue it is on) over the lifetime of a job. To do this, we must keep in mind our workload: a mix of interactive jobs that are short-running (and may frequently relinquish the CPU), and some longer-running “CPU-bound” jobs that need a lot of CPU time but where response time isn’t important.

Here is our first attempt at a priority-adjustment algorithm:

  • Rule 3: When a job enters the system, it is placed at the highest priority (the topmost queue).

  • Rule 4a: If a job uses up an entire time slice while running, its priority is reduced (i.e., it moves down one queue).

  • Rule 4b: If a job gives up the CPU before the time slice is up, it stays at the same priority level.

Example 1: a single long-running job

Let’s look at some examples. First, we’ll look at what happens when there has been a long-running job in the system. The figure below shows what happens to this job over time in a three-queue scheduler.

Get hands-on with 1200+ tech skills courses.