Operating systems use various scheduling algorithms to schedule the execution of different processes on the CPU. Some scheduling algorithms are as follows:
First come first served (FCFS) scheduling
Shortest job next (SJN) scheduling
Priority scheduling
Shortest remaining time
Round robin (RR) scheduling
Multiple-level queues scheduling
Note: Algorithms are either
or preemptive Preemptive scheduling is based on priority where a scheduler may preempt a low priority running process anytime when a high priority process enters into a ready state. . non-preemptive Non-preemptive algorithms are designed so that once a process enters the running state, it cannot be preempted until it completes its allotted time.
In this answer, we'll discuss the multiple-level queues scheduling algorithm.
All ready-state queue processes can be classified into different classes in multiple-level queue scheduling. Each class can follow its scheduling algorithm based on its requirements.
Note: This scheduling can be preemptive or non-preemptive, depending on the conditions of the processes.
For instance, a standard division of processes is between a foreground (interactive) process and a background (batch) process. Both of these processes need different scheduling. In such cases, we use multilevel queue scheduling. Both processes are permanently assigned to separate queues based on some requirements or properties such as process priority or process type, and then each queue can follow separate scheduling.
Suppose we have five following processes of different nature. Let's schedule them using a multilevel queue scheduling:
Process ID | Process Type | Description |
P1 | System Process | The core process of OS. |
P2 | Interactive Process | A process with the same type of interaction. |
P3 | Interactive Editing Process | A type of interactive process. |
P4 | Batch Process | An OS feature that collects data and instructions into a batch before processing. |
P5 | Student Process | Process of lowest priority. |
Let's handle this process scheduling using multilevel queue scheduling. To understand this better, look at the figure below:
The above illustration shows the division of queues based on priority. Every single queue has an absolute priority over the low-priority queue, and no other process is allowed to execute until the high-priority queues are empty. For instance, if the interactive editing process enters the ready queue while the batch process is underway, then the batch process will be preempted.
Let's take a numerical example now:
Process | Arrival Time | Burst Time | Queue Number |
P1 | 0 | 4 | 1 |
P2 | 0 | 3 | 1 |
P3 | 0 | 8 | 2 |
P4 | 10 | 5 | 4 |
The queue number
Let's look at the
The two queues are handled at the start. Queue 1 run first because it has high priority using round-robin scheduling and finishes the execution after 7 unit time.
After queue 1, the process from queue 2 starts execution. While it is executing, process P4 enters Queue 1 and interrupts the execution of P3, and then P3 takes the CPU until its execution.
The advantages of multilevel queue scheduling are the following:
Users can apply different scheduling methods to every queue to distinguish the processes.
The scheduling overhead is very low.
The disadvantages of multilevel queue scheduling are the following:
The process may go into starvation if it has low priority.
This scheduling is rigid and difficult to implement.
Free Resources