Skip to content Skip to sidebar Skip to footer

Multilevel Feedback Queue Scheduling Example With Gantt Chart

Multilevel Feedback Queue Scheduling Example With Gantt Chart

Multilevel Feedback Queue Scheduling (MFQS) is a type of scheduling algorithm used in operating systems. It is a combination of multiple queues and feedback mechanisms that provides better performance and responsiveness to the system. This article will explain the concept of MFQS and provide an example of how it works with a Gantt chart.

Concept of Multilevel Feedback Queue Scheduling

Concept Of Multilevel Feedback Queue Scheduling

The concept of MFQS is based on the idea of multiple queues with different priorities. Each queue is assigned a priority level, and processes are placed in the queue according to their priority. In this algorithm, a process can move up or down in the queue depending on its behavior.

MFQS provides a feedback mechanism that allows a process to move up or down in the queue based on its execution time. If a process uses the CPU for a long time, it will be moved down to a lower priority queue to give other processes a chance to execute. If a process uses the CPU for a short time, it will move up to a higher priority queue to get more CPU time.

Example of Multilevel Feedback Queue Scheduling

Example Of Multilevel Feedback Queue Scheduling

Let's consider an example of MFQS with three priority queues: Q0, Q1, and Q2. Q0 has the highest priority, and Q2 has the lowest priority. The time quantum for each queue is as follows: Q0 = 8ms, Q1 = 16ms, and Q2 = 32ms.

Suppose we have four processes: P1, P2, P3, and P4. The arrival time and burst time for each process are as follows:

ProcessArrival TimeBurst Time
P10ms20ms
P20ms15ms
P30ms10ms
P40ms5ms

Initially, all processes are placed in Q0. The CPU executes the processes in Q0 based on their arrival time and priority. The Gantt chart for the first iteration is as follows:

Gantt Chart For The First Iteration

In the first iteration, P1 and P2 are executed for 8ms each, and P3 and P4 are executed for 5ms each. After 8ms, the time quantum for Q0 expires, and the processes are moved to Q1 with a reduced priority. The Gantt chart for the second iteration is as follows:

Gantt Chart For The Second Iteration

In the second iteration, P1 and P2 are executed for 16ms each in Q1, and P3 and P4 are executed for 10ms and 5ms, respectively, in Q0. After 16ms, the time quantum for Q1 expires, and the processes are moved to Q2 with a further reduced priority. The Gantt chart for the third iteration is as follows:

Gantt Chart For The Third Iteration

In the third iteration, P1 and P2 are executed for 32ms each in Q2, and P3 and P4 are executed for 10ms and 5ms, respectively, in Q1. After 32ms, the time quantum for Q2 expires, and the processes are moved to Q2 with the same priority. The Gantt chart for the final iteration is as follows:

Gantt Chart For The Final Iteration

In the final iteration, P1 and P2 are executed for 32ms each in Q2, and P3 and P4 are executed for 10ms and 5ms, respectively, in Q1.

Conclusion

Multilevel Feedback Queue Scheduling is a popular scheduling algorithm used in operating systems. It provides better performance and responsiveness to the system by combining multiple queues with different priorities and feedback mechanisms. This article has provided an example of how MFQS works with a Gantt chart. By understanding the concept of MFQS and its implementation, system administrators can optimize the CPU usage and improve the performance of their systems.

Related video of Multilevel Feedback Queue Scheduling Example With Gantt Chart