Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last Updated: Mar 27, 2024
Medium

Multilevel Feedback Queue Scheduling (MLFQ)

gp-icon
Operating system track
Free guided path
14 chapters
83+ problems
gp-badge
Earn badges and level up

Introduction

Multilevel Feedback Queue Scheduling (MLFQ) is an advanced CPU scheduling method based on the Multilevel Queue (MLQ) approach, but with the added capability for processes to move between queues. This flexibility enhances efficiency compared to traditional multilevel queue scheduling.

multilevel feedback queue scheduling

Scheduling algorithms are created to keep the central processing unit (CPU) occupied. Standard algorithms are extended by the multilayer feedback queue, which has the following design requirements:

  • Divide processes into different ready queues based on the processor's requirements.
  • Prioritize processes with brief CPU bursts.
  • Give processes with high I/O bursts priority.

Fernando J. Corbató was the first to invent the multilevel feedback queue (1962). The Turing Award was given to Corbató for this achievement by the Association for Computing Machinery.

However, multilevel feedback queue scheduling allows a process to transition across queues. MLFQ (Multilevel Feedback Queue Scheduling) continuously analyses processes' behavior (time of execution) and adjusts its priority accordingly.

round robin with time quantum

 

Assume that queues 1 and 2 use round robin with time quantum 4 and 8, respectively, while queue 3 uses FCFS.

Also see, Multilevel Queue Scheduling

What is Multilevel Feedback Queue Scheduling?

Multilevel feedback queue scheduling is a CPU scheduling algorithm that assigns processes to different queues based on their priority and history of resource usage. The algorithm uses multiple queues with different priorities and time quantum, and processes are moved between queues based on their behaviour and performance, improving overall system efficiency.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Characteristics of Multilevel Feedback Queue Scheduling:

Here are the characteristics of Multilevel Feedback Queue Scheduling:

  • It is a type of process scheduling algorithm used in operating systems.
  • It uses multiple queues to categorize processes based on their priority levels.
  • Each queue has its own scheduling algorithm, such as First-In-First-Out (FIFO), Round-Robin, or Priority Scheduling.
  • Processes are initially assigned to the highest priority queue, and their priority decreases as they spend more time in the system.
  • If a process uses too much CPU time or performs I/O operations, it is moved to a lower-priority queue.
  • If a process waits for I/O operations to complete, it is moved to a higher-priority queue to reduce its wait time.
  • The goal of multilevel feedback queue scheduling is to provide better responsiveness for interactive processes while also maintaining fairness among all processes.
  • It can be tuned by adjusting the number of queues, the scheduling algorithm for each queue, and the criteria for moving processes between queues.
  • The complexity of multilevel feedback queue scheduling increases with the number of queues and the complexity of the scheduling algorithms used in each queue.

Recommended Topic, FCFS Scheduling Algorithm

Problems with the implementation above - A process in the lower priority queue may be starved due to some brief processes consuming all of the CPU time.

Approach - A straightforward solution is to increase the priority of all processes at regular intervals and place them all in the highest priority queue.

Features of Multilevel Feedback Queue Scheduling (MLFQ)

The features of Multilevel Feedback Queue Scheduling (MLFQ) are:

  1. Multiple Priority Levels: MLFQ organizes processes into multiple priority queues, each representing different levels of priority based on process characteristics such as CPU burst time or historical behavior.
  2. Dynamic Priority Assignment: Processes move between priority queues dynamically based on their behavior and resource usage. Lower-priority processes may escalate to higher-priority queues if they exhibit characteristics of short-term CPU-bound behavior.
  3. Time Slice Variation: Each priority queue is allocated a different time quantum or time slice. Higher-priority queues typically receive shorter time slices to promote responsiveness, while lower-priority queues receive longer time slices to prevent starvation.
  4. Preemption and Aging: MLFQ employs preemption to ensure that high-priority processes can interrupt lower-priority ones if necessary. Additionally, processes waiting in lower-priority queues gradually receive increased priority over time to prevent indefinite blocking or starvation.
  5. Adaptive Scheduling: MLFQ adjusts its scheduling parameters dynamically based on system load and process behavior. It aims to strike a balance between fairness, responsiveness, and efficiency in resource utilization.
  6. Avoidance of Priority Inversion: MLFQ helps prevent priority inversion issues by allowing higher-priority processes to preempt lower-priority ones, ensuring that critical tasks receive timely execution.

Advantages of Multilevel Feedback Queue Scheduling

The following are some of the benefits of MFQS.

  • The MFQS algorithm is a flexible scheduling method.
     
  • It allows various processes to switch across queues.
     
  • Prevents CPU overload.
     
  • After a specific amount of time, a mechanism known as Aging helps move a lower priority activity to the next higher priority queue.

Disadvantages of Multilevel Feedback Queue Scheduling

The following are MFQS's drawbacks.

  • It is the most challenging algorithm for scheduling.
     
  • Other methods are required to choose the optimum scheduler.
     
  • There may be CPU overheads associated with this operation.

The need for Multilevel Feedback Queue Scheduling

  • This method is more adaptable than multilevel queue scheduling.
     
  • This method contributes to a faster reaction time.
     
  • The SJF method, which requires the running duration of processes to schedule them, is needed to optimize the turnaround time. As we all know, the course of a procedure cannot be predicted in advance. Furthermore, this scheduling mostly runs a process for a time quantum before changing the process' priority if the process is lengthy. As a result, our scheduling algorithm primarily learns from previous process behavior before predicting future process behavior. As a result, MFQS seeks to execute a shorter process first, which helps to reduce turnaround time.

Multilevel Feedback Queue Scheduling Example

Here are some examples of Multilevel Feedback Queue Scheduling:

  1. A system has three queues, Q0, Q1, and Q2. Q0 is the highest priority queue and uses Round-Robin scheduling with a time quantum of 8 milliseconds. Q1 uses Round-Robin scheduling with a time quantum of 16 milliseconds, and Q2 uses First-Come-First-Serve (FCFS) scheduling. New processes are assigned to Q0, and their priority decreases as they spend more time in the system. If a process completes its time quantum in Q0, it is moved to Q1. If it completes its time quantum in Q1, it is moved to Q2.
  2. A system has four queues, Q0, Q1, Q2, and Q3. Q0 is the highest priority queue and uses Priority Scheduling, where the priority of a process is based on its CPU burst time. Q1 uses Round-Robin scheduling with time quantum of 8 milliseconds. Q2 uses Round-Robin scheduling with a time quantum of 16 milliseconds, and Q3 uses FCFS scheduling. New a are assigned to Q0, and their priority decreases as they spend more time in the system. If a process completes its time quantum in Q0, it is moved to Q1. If it completes its time quantum in Q1, it is moved to Q2. If it completes its time quantum in Q2, it is moved to Q3.
     

Q1, Q2, and Q3 are the three queues.

  • Quantum time nine milliseconds Q1
     
  • Eighteen milliseconds is the time quantum Q2.
     
  • FCFS Q3
     

Multilevel Feedback Queue Criteria

  • Start, all processes in Q1 are completed.
     
  • Processes in Q2 are run when Q1 is empty.
     
  • When Q1 and Q2 are both empty, Q3 processes will run.
     
  • If a procedure is scheduled for Q2, it will take precedence over the process planned for Q3. Similarly, if a process arrives in Q3 before the current process, it will preempt it in Q3. In Q3, operations are conducted on an FCFS basis.
Multilevel Feedback Queue Criteria

You can also read about layered structure of operating system.

Implementation of MFQS

  • When a process begins to run, it is placed in queue 1.
     
  • The priority of the queue 1 process does not change whether it completes or gives CPU for I/O operation in this 4 unit, and if it returns to the ready queue, it resumes its execution in Queue 1.
     
  • If a process in queue 1 does not finish in four units, it loses priority and will move to queue 2.
     
  • Points 2 and 3 apply to queue two processes as well. However, the time quantum is eight units.
     
  • If a process does not finish in a time quantum, it will move to the next time quantum.
     
  • Processes are scheduled in an FCFS fashion in the final queue.
     
  • Lower priority queue processes can only run when higher priority queues are empty.
     
  • A lower priority queue process is paused when a higher priority queue function arrives.

Frequently Asked Questions

What is multilevel feedback queue scheduling?

It's a CPU scheduling method where processes are assigned to different priority queues, with varying time slices, and can move between queues based on their behavior.

What is multi-level queuing schedule technique?

It's a scheduling method that categorizes processes into multiple queues based on criteria like priority or process characteristics, each with its own scheduling algorithm.

What is multilevel feedback queue scheduling in Solaris?

In Solaris, the multilevel feedback queue scheduling algorithm dynamically adjusts process priorities and time slices based on their behavior, optimizing system performance.

Is multilevel queue scheduling preemptive or non preemptive?

Multilevel queue scheduling can be either preemptive or non-preemptive, depending on whether processes can be forcibly interrupted while executing to allow higher-priority processes to run.

Conclusion

This article has gone through an essential topic multilevel feedback queue scheduling. MFQS (Multilevel Feedback Queue Scheduling) continuously analyses the behaviour (time of execution) of processes and adjusts its priority accordingly.

Check out all the articles related to Operating Systems in the Operating Systems Section of our Library.

Recommended Readings: 


Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, Uber, Microsoft, etc. on Coding Ninjas Studio.

Attempt our Online Mock Test Series on Coding Ninjas Studio now!

Ninja, have a great time learning.

Previous article
Multilevel Queue Scheduling
Next article
Lottery Process Scheduling
Guided path
Free
gridgp-icon
Operating system track
14 chapters
83+ Problems
gp-badge
Earn badges and level up
Live masterclass