You are on page 1of 17

OSY22517) Multilevel Queue Scheduling

Abstract
Multilevel queue scheduling is a fundamental process management strategy used in modern
operating systems to efficiently manage processes with varying priorities and characteristics.
In this approach, processes are categorized into multiple priority-based queues, each with its
own scheduling policy and priority level. This segmentation ensures that high-priority
processes, such as system-critical tasks, receive immediate attention, while other processes,
such as interactive, batch, and student processes, are managed separately. This abstract
provides an overview of multilevel queue scheduling, its core principles, and its practical
applications in optimizing system performance and resource allocation.

The primary objective of multilevel queue scheduling is to strike a balance between system
stability, fairness, and responsiveness. By employing different scheduling policies for each
queue, the algorithm can ensure that critical system functions are executed promptly,
maintaining system reliability and preventing bottlenecks. Simultaneously, user interactions
are facilitated by providing short time quanta to interactive processes, offering a snappy user
experience. Batch and student processes, which are typically non-urgent and can be executed
in the background, are assigned lower priorities to avoid disruption of more critical tasks.

The adaptability of multilevel queue scheduling makes it a versatile tool in handling complex,
real-world scenarios. It allows for a mix of scheduling policies, such as First-Come-First-
Serve (FCFS), Round Robin, or Priority Scheduling, tailored to the specific requirements of
each process queue. This adaptability is particularly valuable in optimizing system
performance and resource allocation. However, configuring the priorities and time quantums
for each queue is crucial to achieving the desired system behavior. Multilevel queue
scheduling remains an essential component of modern operating systems, enabling them to
efficiently handle diverse types of processes and maintain system stability.

1
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

INTRODUCTION
The Multilevel Queue Scheduling is a dynamic scheduling algorithm used in operating
systems to manage the execution of multiple processes. In a computing environment, where
various processes with differing priority levels and execution characteristics compete for
system resources, an efficient scheduling mechanism becomes essential. Multilevel Queue
Scheduling is a powerful solution to this problem.

Multilevel Queue Scheduling in operating systems provides an effective means to manage the
dynamic and diverse workloads of modern computing environments. By categorizing
processes into different priority queues and applying specific scheduling policies to each, it
ensures that high-priority tasks receive timely attention while still allowing for the execution
of lower-priority background processes. This makes it a crucial component of responsive and
efficient operating systems.

multilevel queue-scheduling algorithm with five queues:

1. System Processes

2. Interactive Processes

3. Interactive Editing Processes

4. Batch Processes

5. Student Process

Each queue has absolute priority over lower-priority queues. No process in the batch
queue, for example, could run unless the queues for system processes, interactive
processes, and interactive editing processes were all empty. If an interactive editing
process entered the ready queue while a batch process was running, the batch process will
be preempted.

2
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Diagram :

In this case, if there are no processes on the higher priority queue only then the processes on
the low priority queues will run. For Example: Once processes on the system queue, the
Interactive queue, and Interactive editing queue become empty, only then the processes on
the batch queue will run.

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

he program you provided is related to process scheduling in an operating system. It involves


categorizing and sorting processes based on their nature, whether they are system processes,
interactive processes, batch processes, or student processes. Below, I provide a more detailed
explanation of each process type and how they are managed using a multilevel queue
scheduling approach:

1. System Process:

3
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

System processes represent the core operations of the operating system itself.
These processes are responsible for managing and controlling various aspects of
the computer system, such as memory management, hardware resource allocation,
and I/O operations.

In the context of process scheduling, system processes typically receive the


highest priority because they are crucial for the functioning of the operating
system.

2. Interactive Process:

Interactive processes are those that require direct user interaction or real-time
responsiveness. These processes are often associated with tasks like running
online games or applications where user input and output are essential for a
smooth and responsive user experience.

Interactive processes typically receive a relatively high priority to ensure that user
interactions are processed promptly.

3. Batch Processes:

Batch processing involves grouping multiple jobs or tasks together in a batch.


These jobs are processed without user interaction, often in the background. Batch
processes are common in scenarios like large data processing or running
automated scripts.

In the context of scheduling, batch processes may receive moderate priority, and
they are often executed in the order they are received.

4. Student Process:

The term "student process" suggests that these processes are of lower priority
compared to system and interactive processes. Student processes are usually non-
critical or non-urgent tasks that run in the background.

These processes are assigned lower priority to ensure that they do not interfere
with critical system operations or user interactions. Student processes may include
tasks like background downloads, maintenance processes, or non-essential
applications.
4
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

To efficiently manage these different types of processes with varying priorities, the program
employs a multilevel queue scheduling approach. Multilevel queue scheduling divides the
processes into different priority queues, each associated with a different priority level. The
highest-priority queue is typically reserved for system processes, while lower-priority queues
handle interactive, batch, and student processes.

This approach ensures that critical system operations are given priority while still allowing
for the execution of less critical tasks in a fair and organized manner. It helps maintain a
balance between system responsiveness and efficient resource utilization.

5
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Objectives
The objectives of the project are to develop a process scheduling and performance analysis
tool for an operating system. These objectives encompass the primary goals and outcomes
that the project is intended to achieve:

1. Categorize Processes: Categorize processes into different priority levels based on


their nature, such as system processes, interactive processes, batch processes, and
student processes.

2. Implement Multilevel Queue Scheduling: Implement a multilevel queue


scheduling algorithm to organize and manage processes efficiently.

3. User Interaction: Allow user interaction to input process details and control the
execution of the program.

4. Performance Analysis: Calculate and analyze key performance metrics,


including waiting times and turnaround times for each process.

5. Average Metrics Calculation: Compute and display the average waiting time
and average turnaround time to assess the efficiency of the scheduling algorithm.

6. Clear Results Display: Present the performance results in a tabular format to


provide a visual representation of the scheduling performance for each process.

7. Educational Tool: Serve as an educational tool for understanding process


scheduling and the impact of different priority levels on system performance.

8. Scalability: Enable the tool to handle varying numbers of processes and provide
performance insights for different scenarios.

9. Learning Experience: Offer users an opportunity to gain insights into process


scheduling concepts, including multilevel queue scheduling.

10. Simulation of Scheduling: Simulate the scheduling and analysis of processes


without actual process execution on an operating system.
6
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

11. Project Documentation: Provide documentation or user guides to explain the


tool's functionality and usage.

12. Performance Assessment: Enable users to assess the effectiveness of the


scheduling algorithm in managing processes with different priorities.

13. Code Development: Develop a working C program to accomplish the above


objectives.

The project's objectives are designed to create a practical and educational tool that allows
users to interact with a simulated process scheduling system. It helps users understand how
process priorities impact system performance and provides valuable insights into multilevel
queue scheduling.

7
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Algorithm

1. Initialize arrays and variables for process information and calculations.

2. Prompt the user for the number of processes (n).

3. Input process details (ID, burst time, system/user indicator) for each process in a loop.

4. Sort the processes based on the system/user indicator (0 for system, 1 for user).

5. Initialize the waiting time and turnaround time for the first process.

6. Calculate waiting times and turnaround times for each process in a loop.

7. Calculate the average waiting time and average turnaround time.

8. Display the results in a table format, including process details, system/user indicator, burst
time, waiting time, and turnaround time.

9. Print the average waiting time and average turnaround time.

10. Exit the program.

8
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Implementation
#include<stdio.h>

int main()

int p[20],bt[20], su[20], wt[20],tat[20],i, k, n, temp;

float wtavg, tatavg;

printf("Enter the number of processes:");

scanf("%d",&n);

for(i=0;i<n;i++)

p[i] = i;

printf("Enter the Burst Time of Process%d:", i);

scanf("%d",&bt[i]);

printf("System/User Process (0/1) ? ");

scanf("%d", &su[i]);

for(i=0;i<n;i++)

for(k=i+1;k<n;k++)

if(su[i] > su[k])

temp=p[i];

p[i]=p[k];

p[k]=temp;

temp=bt[i];
9
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

bt[i]=bt[k];

bt[k]=temp;

temp=su[i];

su[i]=su[k];

su[k]=temp;

wtavg = wt[0] = 0;

tatavg = tat[0] = bt[0];

for(i=1;i<n;i++)

wt[i] = wt[i-1] + bt[i-1];

tat[i] = tat[i-1] + bt[i];

wtavg = wtavg + wt[i];

tatavg = tatavg + tat[i];

printf("\nPROCESS\t\t SYSTEM/USER PROCESS \tBURST TIME\tWAITING


TIME\tTURNAROUND TIME");

for(i=0;i<n;i++)

printf("\n%d \t\t %d \t\t %d \t\t %d \t\t %d ",p[i],su[i],bt[i],wt[i],tat[i]);

printf("\nAverage Waiting Time is --- %f",wtavg/n);

printf("\nAverage Turnaround Time is --- %f",tatavg/n);

return 0;

10
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Output

11
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

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.

12
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Features
1. 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.

2. 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.

3. 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.

4. 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.

5. 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.

6. 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.

7. Fairness: MLQ scheduling provides a fair allocation of CPU time to different types of
processes, based on their priority and requirements.

8. Customizable: MLQ scheduling can be customized to meet the specific requirements


of different types of processes.

13
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Advantages

1. 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.

2. 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.

3. Fairness: The scheduling algorithm provides a fair allocation of CPU time to


different types of processes, based on their priority and requirements.

4. 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.

5. Prioritization: Priorities are assigned to processes based on their type, characteristics,


and importance, which ensures that important processes are executed in a timely
manner.

6. 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.

14
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Disadvantages
1. Some processes may starve for CPU if some higher priority queues are never
becoming empty.

2. It is inflexible in nature.

3. There may be added complexity in implementing and maintaining multiple queues


and scheduling algorithms.

4. There are chances of starvation for lower-priority processes. If higher-priority


processes keep coming, then the lower-priority processes won't get an opportunity to
go into the running state.

5. Multilevel queue scheduling is inflexible.

15
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

Conclusion
In conclusion, the multilevel queue scheduling project is a sophisticated and effective
approach to managing the allocation of resources and prioritizing processes in a computer
system. By dividing processes into different queues based on their characteristics and
assigning appropriate priorities, this scheduling algorithm helps ensure efficient resource
utilization, fairness, and responsiveness to varying workloads. It is a valuable tool for
optimizing system performance and meeting the diverse requirements of modern computing
environments.

Multilevel queue scheduling is a sophisticated process management technique used in


operating systems to efficiently handle a variety of tasks with different priorities. The
approach categorizes processes into multiple priority-based queues, enabling the operating
system to manage them effectively. By segregating processes into distinct queues, multilevel
queue scheduling can ensure that system-critical processes receive the highest priority,
preventing potential system bottlenecks or crashes. Simultaneously, it allows user processes,
batch tasks, and student processes to be handled with fairness and responsiveness, optimizing
resource allocation and system stability.

One of the notable advantages of multilevel queue scheduling is its adaptability to diverse
real-world scenarios. In practical operating systems, processes often exhibit varying
execution requirements, and this scheduling algorithm excels in managing such complexity.
Additionally, each queue within the multilevel structure can employ a different scheduling
algorithm, providing flexibility to tailor the scheduling approach to meet specific system
demands. This versatility ensures that the algorithm can effectively manage a wide range of
workloads while maintaining optimal system performance. Nonetheless, configuring the
priorities and time quantums for each queue accurately is critical to ensuring the desired
outcome and avoiding resource underutilization or performance degradation. Overall,
multilevel queue scheduling remains a valuable tool for achieving efficient resource
allocation and performance optimization in complex computing environments.

Reference
16
GT &MC Vishnupuri, Nanded
OSY22517) Multilevel Queue Scheduling

https://www.javatpoint.com/multilevel-queue-scheduling-in-operating-
system#:~:text=Each%20algorithm%20supports%20a%20different,whose
%20execution%20can%20be%20delayed.

https://www.geeksforgeeks.org/multilevel-queue-mlq-cpu-scheduling/

https://www.studytonight.com/operating-system/multilevel-queue-scheduling

17
GT &MC Vishnupuri, Nanded

You might also like