Multilevel Queue (MLQ) CPU Scheduling

Last Updated : 05 May, 2023
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

It may happen that processes in the ready queue can be divided into different classes where each class has its own scheduling needs. For example, a common division is a foreground (interactive) process and a background (batch) process. These two classes have different scheduling needs. For this kind of situation, Multilevel Queue Scheduling is used. 

Now, let us see how it works. 

Features of Multilevel Queue (MLQ) CPU Scheduling:

  • Multiple queues: In MLQ scheduling, processes are divided into multiple queues based on their priority, with each queue having a different priority level. Higher-priority processes are placed in queues with higher priority levels, while lower-priority processes are placed in queues with lower priority levels.
  • Priorities assigned: Priorities are assigned to processes based on their type, characteristics, and importance. For example, interactive processes like user input/output may have a higher priority than batch processes like file backups.
  • Preemption: Preemption is allowed in MLQ scheduling, which means a higher priority process can preempt a lower priority process, and the CPU is allocated to the higher priority process. This helps ensure that high-priority processes are executed in a timely manner.
  • Scheduling algorithm: Different scheduling algorithms can be used for each queue, depending on the requirements of the processes in that queue. For example, Round Robin scheduling may be used for interactive processes, while First Come First Serve scheduling may be used for batch processes.
  • Feedback mechanism: A feedback mechanism can be implemented to adjust the priority of a process based on its behavior over time. For example, if an interactive process has been waiting in a lower-priority queue for a long time, its priority may be increased to ensure it is executed in a timely manner.
  • Efficient allocation of CPU time: MLQ scheduling ensures that processes with higher priority levels are executed in a timely manner, while still allowing lower priority processes to execute when the CPU is idle.
  • Fairness: MLQ scheduling provides a fair allocation of CPU time to different types of processes, based on their priority and requirements.
  • Customizable: MLQ scheduling can be customized to meet the specific requirements of different types of processes.

Advantages of Multilevel Queue CPU Scheduling:

  • Low scheduling overhead: Since processes are permanently assigned to their respective queues, the overhead of scheduling is low, as the scheduler only needs to select the appropriate queue for execution.
  • Efficient allocation of CPU time: The scheduling algorithm ensures that processes with higher priority levels are executed in a timely manner, while still allowing lower priority processes to execute when the CPU is idle. This ensures optimal utilization of CPU time.
  • Fairness: The scheduling algorithm provides a fair allocation of CPU time to different types of processes, based on their priority and requirements.
  • Customizable: The scheduling algorithm can be customized to meet the specific requirements of different types of processes. Different scheduling algorithms can be used for each queue, depending on the requirements of the processes in that queue.
  • Prioritization: Priorities are assigned to processes based on their type, characteristics, and importance, which ensures that important processes are executed in a timely manner.
  • Preemption: Preemption is allowed in Multilevel Queue Scheduling, which means that higher-priority processes can preempt lower-priority processes, and the CPU is allocated to the higher-priority process. This helps ensure that high-priority processes are executed in a timely manner.

Disadvantages of Multilevel Queue CPU Scheduling:

  • Some processes may starve for CPU if some higher priority queues are never becoming empty.
  • It is inflexible in nature.
  • There may be added complexity in implementing and maintaining multiple queues and scheduling algorithms.

Ready Queue is divided into separate queues for each class of processes. For example, let us take three different types of processes System processes, Interactive processes, and Batch Processes. All three processes have their own queue. Now, look at the below figure. 

The Description of the processes in the above diagram is as follows:

  • System Processes: The CPU itself has its own process to run which is generally termed a System Process.
  • Interactive Processes: An Interactive Process is a type of process in which there should be the same type of interaction.
  • Batch Processes: Batch processing is generally a technique in the Operating system that collects the programs and data together in the form of a batch before the processing starts.

All three different type of processes have their own queue. Each queue has its own Scheduling algorithm. For example, queue 1 and queue 2 use Round Robin while queue 3 can use FCFS to schedule their processes. 

Scheduling among the queues: What will happen if all the queues have some processes? Which process should get the CPU? To determine this Scheduling among the queues is necessary. There are two ways to do so – 

  1. Fixed priority preemptive scheduling method – Each queue has absolute priority over the lower priority queue. Let us consider the following priority order queue 1 > queue 2 > queue 3. According to this algorithm, no process in the batch queue(queue 3) can run unless queues 1 and 2 are empty. If any batch process (queue 3) is running and any system (queue 1) or Interactive process(queue 2) entered the ready queue the batch process is preempted.
  2. Time slicing – In this method, each queue gets a certain portion of CPU time and can use it to schedule its own processes. For instance, queue 1 takes 50 percent of CPU time queue 2 takes 30 percent and queue 3 gets 20 percent of CPU time.

Example Problem:

Consider the below table of four processes under Multilevel queue scheduling. Queue number denotes the queue of the process. 

Priority of queue 1 is greater than queue 2. queue 1 uses Round Robin (Time Quantum = 2) and queue 2 uses FCFS. 

Below is the Gantt chart of the problem: 

 

Working:

  • At starting, both queues have process so process in queue 1 (P1, P2) runs first (because of higher priority) in the round-robin fashion and completes after 7 units
  • Then process in queue 2 (P3) starts running (as there is no process in queue 1) but while it is running P4 comes in queue 1 and interrupts P3 and start running for 5 seconds and 
  • After its completion P3 takes the CPU and completes its execution. 

 



Next Article

Similar Reads

Difference between Multilevel Queue (MLQ) and Multi Level Feedback Queue (MLFQ) CPU scheduling algorithms
In multi programming environment, it often happens that more than one processes compete for CPU resources at the same time. If only one CPU is available choice has to be made between processes to run next. Part of the Operating System responsible for making choice of process is called Scheduler and the algorithm it used is called Scheduling Algorit
3 min read
Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling
Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling is like Multilevel Queue(MLQ) Scheduling but in this process can move between the queues. And thus, much more efficient than multilevel queue scheduling. Characteristics of Multilevel Feedback Queue Scheduling: In a multilevel queue-scheduling algorithm, processes are permanently assigned t
5 min read
Difference between Multi Level Queue Scheduling (MLQ) and Priority Scheduling
1. Multi Level Queue Scheduling (MLQ) : It is quite difficult to have just one queue and schedule all processes. This is where multi-level queue scheduling is used. In this, processes are divided into various classes depending upon property of processes such as system process, I/O process, etc. Thus we get 'n' number of queues for n classes of proc
3 min read
Difference between Multi Level Queue (MLQ) Scheduling and Round Robin (RR) algorithms
1. Multi Level Queue Scheduling (MLQ) : It is quite difficult to have just one queue and schedule all the processes. This is where multi-level queue scheduling is used. In this the processes are divided into various classes depending upon the property of the processes such as system process, I/O process, etc. Thus we get 'n' number of queues for n
3 min read
Difference between Multi Level Queue Scheduling (MLQ) and First Come First Served (FCFS)
1. Multi Level Queue Scheduling (MLQ) : It is quite difficult to have just one queue and schedule all the processes. This is where multi level queue scheduling is used. In this the processes are divided into various classes depending upon the property of the processes such as system process, I/O process etc. Thus we get 'n' number of queues for n c
3 min read
Difference between Multi Level Queue Scheduling (MLQ) and Shortest Job First
1. Multi Level Queue Scheduling (MLQ) : It is quite difficult to have just one queue and schedule all the processes. This is where multi level queue scheduling is used. In this the processes are divided into various classes depending upon the property of the processes such as system process, I/O process etc. Thus we get 'n' number of queues for n c
3 min read
Difference between Multi Level Queue Scheduling (MLQ) and Longest Job First (LJF)
1. Multi Level Queue Scheduling (MLQ) : It is quite difficult to have just one queue and schedule all processes. This is where multi-level queue scheduling is used. In this, processes are divided into various classes depending upon property of processes such as system process, I/O process, etc. Thus we get 'n' number of queues for n classes of proc
3 min read
Difference between Priority Scheduling and Round Robin (RR) CPU scheduling
1. Priority Scheduling Algorithm : Priority scheduling algorithm executes the processes depending upon their priority. Each process is allocated a priority and the process with the highest priority is executed first. Priorities can be defined internally as well as externally. Internal priorities are decided by the system depending upon the number o
3 min read
Difference between Priority scheduling and Shortest Job First (SJF) CPU scheduling
1. Priority Scheduling Algorithm : Priority scheduling algorithm executes the processes depending upon their priority. Each process is allocated a priority and the process with the highest priority is executed first. Priorities can be defined internally as well as externally. Internal priorities are decided by the system depending upon the number o
3 min read
Difference Between User-CPU-Time and System-CPU-Time in UNIX
There are two kinds of CPU time in any UNIX system: User CPU Time and System CPU Time. These metrics help in understanding the way in which the overall execution time is spent by any process using CPU resources. User CPU time is the total amount of time that the CPU spends executing both user processes and those parts of programs that run on behalf
8 min read
Operating Systems | CPU Scheduling | Question 1
Consider three processes (process id 0, 1, 2 respectively) with compute time bursts 2, 4 and 8 time units. All processes arrive at time zero. Consider the longest remaining time first (LRTF) scheduling algorithm. In LRTF ties are broken by giving priority to the process with the lowest process id. The average turn around time is: (A) 13 units (B) 1
1 min read
Operating Systems | CPU Scheduling | Question 2
Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units, respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing computation, and the last 10% of time doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm a
2 min read
Difference between Preemptive Priority based and Non-preemptive Priority based CPU scheduling algorithms
Prerequisite - CPU Scheduling Priority Scheduling : In priority scheduling, each process has a priority which is an integer value assigned to it. The smallest integer is considered as the highest priority and the largest integer is considered as the lowest priority. The process with the highest priority gets the CPU first. In rare systems, the larg
4 min read
Longest Remaining Time First (LRTF) CPU Scheduling Program
We have given some processes with arrival time and Burst Time and we have to find the completion time (CT), Turn Around Time(TAT), Average Turn Around Time (Avg TAT), Waiting Time(WT), Average Waiting Time (AWT) for the given processes. Prerequisite: CPU Scheduling | Longest Remaining Time First (LRTF) algorithm LRTF is a preemptive scheduling algo
15+ min read
Difference between Turn Around Time (TAT) and Waiting Time (WT) in CPU Scheduling
In CPU Scheduling, we often need to find the average Turnaround and Waiting Time with the help of Arrival, Burst and Completion Time. Let's have a brief look of them: Turnaround Time (TAT): It is the time interval from the time of submission of a process to the time of the completion of the process.The difference b/w Completion Time and Arrival Tim
2 min read
Advantages and Disadvantages of various CPU scheduling algorithms
CPU Scheduling involves many different scheduling algorithms which have their Advantages and Disadvantages. 1. First Come First Serve (FCFS): Advantages: It is simple and easy to understand.FCFS provides fairness by treating all processes equally and giving them an equal opportunity to run.FCFS guarantees that every process will eventually get a ch
3 min read
Difference between SJF and LJF CPU scheduling algorithms
Shortest Job First: The shortest job first (SJF) algorithm is a CPU scheduling algorithm designed to reorder the jobs so that the process having the smallest burst time is chosen for the next execution. It is used to reduce the average waiting time for other processes waiting for execution. This may be preemptive or non-preemptive. Its preemptive v
4 min read
Fair-share CPU scheduling
Fair-share scheduling is a scheduling algorithm that was first designed by Judy Kay and Piers Lauder at Sydney University in the 1980s. It is a scheduling algorithm for computer operating systems that dynamically distributes the time quanta "equally" to its users. Time quantum is the processor time allowed for a process to run. But in a round-robin
2 min read
Difference between SJF and SRJF CPU scheduling algorithms
1. Shortest Job First (SJF) : The Shortest Job First (SJF) is a scheduling policy that selects the waiting process with the smallest execution time to execute next. It is also known as Shortest Job Next (SJN) or Shortest Process Next (SPN). It is a non-preemptive scheduling algorithm. 2. Shortest Remaining Job First (SRTF) : The Shortest Remaining
2 min read
Difference between SRJF and LRJF CPU scheduling algorithms
1. Shortest remaining job first (SRJF) : Shortest remaining job first also called the shortest remaining time first is the preemptive version of the shortest job first scheduling algorithm. In the shortest remaining job first, the process with the smallest runtime to complete (i.e remaining time) is scheduled to run next, In SRJF, a running process
3 min read
Difference between Arrival Time and Burst Time in CPU Scheduling
CPU scheduling algorithms require CPU time and IO time required for its execution. CPU time is time taken by CPU to carry out the process while I/O time illustrates the time required for I/O operation by the process. The execution of multiple processes in an optimised way is based on different kinds of algorithms, like FCFS, Shortest Job First etc.
3 min read
Difference between First Come First Served (FCFS) and Longest Job First (LJF) CPU scheduling algorithms
1.First Come First Served (FCFS) : First Come First Served (FCFS) is the simplest type of algorithm. It is a non-preemptive algorithm i.e. the process cannot be interrupted once it starts executing. The FCFS is implemented with the help of a FIFO queue. The processes are put into the ready queue in the order of their arrival time. The process that
3 min read
Difference between FCFS and Priority CPU scheduling
1. First Come First Served (FCFS) : First Come First Served (FCFS) is the simplest type of algorithm. It is a non-preemptive algorithm i.e. the process cannot be interrupted once it starts executing. The FCFS is implemented with the help of a FIFO queue. The processes are put into the ready queue in the order of their arrival time. The process that
3 min read
Longest Job First (LJF) CPU Scheduling Algorithm
Longest Job First (LJF) is a non-preemptive scheduling algorithm. This algorithm is based on the burst time of the processes. The processes are put into the ready queue based on their burst times i.e., in descending order of the burst times. As the name suggests this algorithm is based on the fact that the process with the largest burst time is pro
5 min read
Deadline Monotonic CPU Scheduling
Prerequisites - CPU Scheduling Preemptive Scheduling Program for Preemptive Priority CPU Scheduling Deadline Monotonic Scheduling : It is a fixed priority based algorithm in which priorities are assigned to each task based on their relative deadline. Task with shortest deadline is assigned highest priority. It is a Preemptive Scheduling Algorithm t
3 min read
Difference between EDF and LST CPU scheduling algorithms
1. Earliest Deadline First (EDF) : In Earliest Deadline First scheduling algorithm, at every scheduling point the task having the shortest deadline is scheduled for the execution. It is an optimal dynamic priority-driven scheduling algorithm used in real-time systems. It uses priorities of the tasks for scheduling. In EDF, priorities to the task ar
4 min read
Difference between LJF and LRJF CPU scheduling algorithms
1. Longest Job First (LJF) : It CPU Scheduling algorithm where the process with the largest burst line is executed first. Once the process enters the ready queue, the process exits only after the completion of execution, therefore it is a non-preemptive process. In case, the burst times of the processes are same, the job with overall lowest time is
2 min read
Time Slicing in CPU scheduling
CPUs kernel doesn't simply distribute the entirety of our PCs' resources to single process or service. CPU is continuously running many processes that are essential for it to operate, so our kernel needs to manage these processes without moment's delay. When program needs to run, process must be created for it. This process needs to have important
3 min read
CPU Scheduling Numerical Questions
1. Find the size of the memory if its address consists of 22 bits. Assume the memory is 2-byte addressable.Solution - If the given address consists of ‘k’ bits, then 2k locations are possible.Size of memory = 2k x Size of one location.According to the question, number of locations with 22 bits = 222 locationsGiven that the size of the memory is 2-b
3 min read
Comparison of Different CPU Scheduling Algorithms in OS
A scheduling algorithm is used to estimate the CPU time required to allocate to the processes and threads. The prime goal of any CPU scheduling algorithm is to keep the CPU as busy as possible for improving CPU utilization. Scheduling Algorithms 1. First Come First Serve(FCFS): As the name implies that the jobs are executed on a first come first se
5 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg