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 background (batch) processes. These two classes have different scheduling needs. For this kind of situation Multilevel Queue Scheduling is used. Now, let us see how it works.
Ready Queue is divided into separate queues for each class of processes. For example, let us take three different types of process System processes, Interactive processes and Batch Processes. All three process have there own queue. Now, look at the below figure.
All three different type of processes have there own queue. Each queue have its own Scheduling algorithm. For example, queue 1 and queue 2 uses Round Robin while queue 3 can use FCFS to schedule there 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:
Example Problem: Consider 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:
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 second and after its completion P3 takes the CPU and completes its execution.
Advantages:
Disadvantages:
This Scheduling is like Multilevel Queue(MLQ) Scheduling but in this process can move between the queues. Multilevel Feedback Queue Scheduling (MLFQ) keep analyzing the behavior (time of execution) of processes and according to which it changes its priority. Now, look at the diagram and explanation below to understand it properly.
Now let us suppose that queue 1 and 2 follow round robin with time quantum 4 and 8 respectively and queue 3 follow FCFS. One implementation of MFQS is given below:
Well, above implementation may differ for example the last queue can also follow Round-robin Scheduling.
Problems in the above implementation: A process in the lower priority queue can suffer from starvation due to some short processes taking all the CPU time.
Solution: A simple solution can be to boost the priority of all the process after regular intervals and place them all in the highest priority queue.
What is the need of such complex Scheduling?
Example: Consider a system which has a CPU bound process, which requires the burst time of 40 seconds. The multilevel Feed Back Queue scheduling algorithm is used and the queue time quantum ‘2’ seconds and in each level it is incremented by ‘5’ seconds.Then how many times the process will be interrupted and on which queue the process will terminate the execution?
Solution:
Advantages:
Disadvantages:
10 videos|99 docs|33 tests
|
1. What is multilevel queue CPU scheduling? |
2. How does multilevel queue CPU scheduling work? |
3. What are the advantages of multilevel queue CPU scheduling? |
4. What are the challenges of implementing multilevel queue CPU scheduling? |
5. Can multilevel queue CPU scheduling be combined with other scheduling algorithms? |
|
Explore Courses for Computer Science Engineering (CSE) exam
|