Multilevel Queues and Multilevel Feedback Queues Scheduling comes under the second category of scheduling algorithms because in this category the processes are classified into different groups. So, let's start, shall we?
Foreground and Background Processes
Multilevel Queues and Multilevel Feedback Queues Scheduling are used to divide foreground and background processes because they have different time requirements. That's why Foreground and Background processes uses different scheduling algorithms.
Let's understand what are these foreground and background processes.
Foreground Processes: These are the processes that require users to start them and interact with them.
Background Processes: These are the processes which operates independently without interaction of any user.
Multilevel Queues Scheduling
The concept of Multilevel Queue Scheduling is pretty straight forward. In this scheduling, the ready queue is divided into several different queues for eg. Batch Processes, System Processes, Interactive Processes. These queues are used to divide foreground processes from background processes. The foreground process might use Round Robin Scheduling and background process uses FCFS Scheduling.
But what if all the queues have some processes in them, then how are we going to schedule these queues?
Let us take an example that we have 3 queues namely queue1, queue2, queue3. Then the queue which has the highest priority is scheduled first. After that the remaining queues ar executed by their priority.
Multilevel FeedBack Queue Scheduling
This scheduling technique is similar to Multilevel Queues Scheduling but the only difference is that here a process can move from queue to another. Multilevel Feedback Queues Scheduling analyzes the behaviour of processes and according to the behaviour it changes its priority.
Consider the above picture. Let queue 1 and queue 2 follows round robin scheduling with time slice 4 and 8. Queue 3 follows FCFS. The working of Multilevel Feedback Queues Scheduling is given below:
- When a process starts execution it enters queue 1.
- If a process in queue 1 does not complete in 4ms then priority of this process is reduced and shifted to queue 2.
- If a process does not complete in given time slice then it is shifted to a lower priority queue.
- In the last queue processes are scheduled in FCFS manner.
- A lower priority queue is executed only when a higher priority process is done with its execution.
- A process running in low priority can only be interrupted by a process arriving in higher priority queue.