Process Scheduling

Process scheduling in operating systems is a fundamental concept that involves managing the order and timing in which processes are executed. It's crucial for optimizing resource utilization, ensuring fairness among processes, and providing a responsive user experience in multitasking environments. To effectively manage various aspects of process execution, operating systems typically employ three types of schedulers: Long-term, Medium-term, and Short-term schedulers, each with distinct roles and responsibilities.

Long-Term Scheduler (Job Scheduler)

  1. Function: The long-term scheduler, or job scheduler, controls the degree of multiprogramming, which is the number of processes that are kept in memory ready to execute. This scheduler decides which programs or jobs are admitted to the system for processing.

  2. Degree of Multiprogramming: This term refers to the number of processes residing in the system's memory at any point in time. A higher degree of multiprogramming allows for more processes to be executed concurrently, potentially improving CPU utilization but also increasing competition for resources.

  3. Responsibilities: The long-term scheduler is responsible for selecting processes from the job pool (a collection of all the jobs waiting for system resources) and loading them into memory for execution. It determines the mix of I/O-bound and CPU-bound processes, which can affect overall system performance.

  4. Frequency: It runs less frequently compared to other schedulers. In many systems, especially batch systems, the long-term scheduler might run only once in a while (e.g., every few seconds or minutes).

Medium-Term Scheduler (Swapping Scheduler)

  1. Function: The medium-term scheduler temporarily removes processes from active contention for CPU to reduce the degree of multiprogramming. This process is often referred to as "swapping out" or "rolling out."

  2. Swapping: Swapping involves moving some processes from main memory to secondary storage (disk) and back to main memory. This is done to manage memory more efficiently and to allow for a mix of process sizes to be handled.

  3. Responsibilities: The medium-term scheduler is primarily concerned with enhancing system performance by balancing the load between memory and CPU. It can swap out processes that are blocked or waiting for an extended period, thereby freeing up memory for other processes.

  4. Frequency: This scheduler operates more frequently than the long-term scheduler but less frequently than the short-term scheduler. The frequency of its operation is often dependent on the current workload and system performance metrics.

Short-Term Scheduler (CPU Scheduler)

  1. Function: The short-term scheduler, also known as the CPU scheduler, decides which of the ready, in-memory processes are to be executed (allocated CPU) next by the processor.

  2. Process Scheduling: This involves selecting a process from the ready queue and allocating the CPU to it. The decision is made based on a particular process scheduling algorithm, like Round-Robin, First-Come-First-Served, or Priority Scheduling.

  3. Responsibilities: The short-term scheduler must ensure that processes are executed in an efficient and fair manner. It's responsible for maintaining a balance between I/O and CPU-bound processes and providing reasonable response times to interactive users.

  4. Frequency: This is the most frequently invoked scheduler, typically running every few milliseconds. Because of its high-frequency operation, it is designed to be as fast as possible to minimize the overhead of context switching.

Together, these three schedulers play a pivotal role in the effective management of processes in an operating system. The long-term scheduler determines the overall mix of jobs in the system, the medium-term scheduler optimizes memory utilization through swapping, and the short-term scheduler manages the immediate allocation of the CPU to processes. This layered approach allows for efficient resource management, ensuring that both user and system processes are executed effectively.

In the context of CPU scheduling and system performance evaluation, several key metrics are used to assess how effectively an operating system manages its processes. These include response time, waiting time, turnaround time, throughput, and arrival time. Understanding these metrics is crucial for evaluating and improving system performance.

1. Response Time

  • Description: Response time is the interval from the time a request (such as starting a process or an I/O operation) is submitted until the first response is produced. In a user-interactive system, this is the time between a user's action and when the user sees some result of that action.

  • Goal: Minimization. Especially critical in interactive systems where user satisfaction depends on immediate feedback.

2. Waiting Time

  • Description: Waiting time refers to the total amount of time a process spends in the ready queue before it gets CPU time. It's the cumulative time a process is ready to run but not actually running.

  • Goal: Minimization. Less waiting time typically implies better process performance and higher system responsiveness.

3. Turnaround Time

  • Description: Turnaround time is the total time taken from the submission of a process to the completion of its execution. This includes all waiting time, execution time, and any I/O or other delays.

  • Goal: Minimization. A lower turnaround time means that processes are completed faster, which is generally desirable.

4. Throughput

  • Description: Throughput is the number of processes completed per unit time. It's a measure of how many tasks can be processed by the system in a given time frame.

  • Goal: Maximization. Higher throughput indicates a more efficient and productive system.

5. Arrival Time

  • Description: Arrival time is the time at which a process enters the system (i.e., the ready queue). It's an important metric for scheduling algorithms that consider the order of process arrival, like First-Come, First-Served (FCFS).

  • Goal: Not applicable for minimization or maximization. It's a reference metric used in scheduling decisions and performance analysis.

Optimization Goals

  • Minimize Response Time: Critical for interactive systems where immediate feedback is important for user experience.

  • Minimize Waiting Time: Leads to better utilization of CPU and system resources and enhances user satisfaction.

  • Minimize Turnaround Time: Ensures that processes complete as quickly as possible, improving overall system efficiency.

  • Maximize Throughput: A higher number of processes handled in a given time improves overall system performance and resource utilization.

  • Arrival Time Considerations: While not a metric to be minimized or maximized, it's crucial for understanding and improving the scheduling algorithm's performance.

CPU scheduling algorithms are essential for determining the order in which processes will be executed by the CPU. They play a crucial role in optimizing resource utilization, ensuring fairness among processes, and enhancing system performance. Here, we'll explore various CPU scheduling algorithms, including their types, characteristics, and the advantages and disadvantages of each.

First-Come, First-Served (FCFS) is one of the simplest types of CPU scheduling algorithms. As its name implies, it schedules processes in the order they arrive in the ready queue, which is essentially a FIFO (First In, First Out) queue. Let's delve deeper into the details of FCFS:

  • Queue Mechanism: Processes that arrive and are ready to execute are placed at the end of the ready queue. The CPU scheduler picks the process at the front of this queue, allocates the CPU to it, and allows it to run until it either finishes or yields the CPU (e.g., due to an I/O request).

  • Non-Preemptive: FCFS is inherently non-preemptive. Once a process starts executing, it keeps the CPU until it either terminates or switches to the waiting state voluntarily. This means that short processes might have to wait for a long time if a lengthy process is executing.


  1. Simplicity and Ease of Implementation: FCFS is straightforward to implement. A basic queue data structure is all that is required to manage the processes. This simplicity makes it an appealing choice, especially in systems where complex scheduling is not needed.

  2. Fairness: The FCFS algorithm is fair in the sense that it strictly adheres to the order in which processes arrive. There is no bias towards short or long processes, or any other attributes like priority. Every process gets its turn in the order it requests CPU time.


  1. Convoy Effect: One of the significant drawbacks of the FCFS algorithm is the so-called "convoy effect." This occurs when a few lengthy processes hold up the CPU, causing a "convoy" of shorter, faster processes to accumulate in the ready queue behind them. This leads to poor resource utilization, as the CPU remains idle during the I/O operations of the long process while several short processes are waiting to execute.

  2. Long Waiting Times: Related to the convoy effect, FCFS can lead to long waiting times, especially for short processes. The average waiting time, especially in a system with varying process lengths, can be quite high.

  3. Not Suitable for Time-Sharing Systems: In time-sharing systems, where the objective is to allow users to interact with the system with minimal delay, FCFS is not an optimal choice. The long waiting times and the inability to preempt long-running processes can lead to a poor user experience.

  4. Lack of Responsiveness: FCFS scheduling does not adapt to the types of processes (CPU-bound or I/O-bound) or their priority. Hence, it is not responsive to varying process requirements, which is a critical aspect in modern, multipurpose operating systems.

Shortest Job First (SJF) is a CPU scheduling algorithm that selects the process with the shortest estimated running time to execute next. It's an efficient algorithm in terms of reducing the average waiting time for processes. SJF can be implemented in both non-preemptive and preemptive manners, known as Shortest Remaining Time First (SRTF) in its preemptive form.

Non-Preemptive SJF

  • Mechanism: In non-preemptive SJF, the CPU scheduler selects the process with the shortest estimated CPU burst time from the ready queue and runs it to completion. Once a process starts executing, it keeps the CPU until it either finishes or voluntarily relinquishes control (e.g., for an I/O operation).

Preemptive SJF (SRTF)

  • Mechanism: The preemptive version, SRTF, allows the scheduler to preempt a currently running process if a new process with a shorter burst time arrives. The preempted process returns to the ready queue, and the new process takes over the CPU.


  1. Minimal Average Waiting Time: SJF is optimal in terms of reducing the average waiting time among all processes. By always choosing the shortest available job, the time that processes spend in the ready queue is minimized.

  2. Increased Throughput: With shorter jobs being processed more quickly, the throughput of the system (the number of processes completed per unit time) can be increased.


  1. Requirement of Burst Time Knowledge: A significant limitation of SJF is that it requires prior knowledge of the CPU burst time for each process. Predicting the exact CPU time requirement is often impractical and can lead to inaccurate scheduling decisions.

  2. Starvation of Longer Processes: Longer processes may suffer from starvation in SJF scheduling. Since the scheduler always favors the shortest job, longer jobs might be indefinitely postponed if shorter jobs keep arriving.

  3. Overhead of Preemption in SRTF: In its preemptive form (SRTF), there's an additional overhead of context switching each time a new process with a shorter burst time arrives, which could lead to reduced CPU efficiency if not managed properly.

  4. Non-Deterministic Behavior: The runtime behavior of SJF can be unpredictable, as it depends on the exact nature of the processes arriving in the system. This unpredictability can make system performance hard to gauge and optimize.


  • Fairness and Responsiveness: While SJF excels in optimizing the average waiting time, it isn't necessarily fair, especially to longer tasks. In interactive systems or systems where response time is critical, SJF may not be the best choice.

  • Implementation Complexity: Accurately implementing SJF requires sophisticated prediction algorithms to estimate process burst times based on historical data. This complexity can make the algorithm less attractive for certain applications.

Priority scheduling is a CPU scheduling algorithm that operates based on the priority of the processes. In this algorithm, each process is assigned a priority, and the scheduler selects the process with the highest priority for execution. This method can be implemented in both non-preemptive and preemptive forms.

Non-Preemptive Priority Scheduling

  • Mechanism: In the non-preemptive version, the scheduler selects the highest-priority process from the ready queue and runs it to completion. Other processes must wait until the running process finishes or until no higher-priority process is in the ready queue.

  • Equal Priority Handling: If two or more processes have the same priority, they are typically scheduled in First-Come, First-Served (FCFS) order.

Preemptive Priority Scheduling

  • Mechanism: In the preemptive variant, if a new process with a higher priority than the currently running process arrives, the current process is preempted. The preempted process returns to the ready queue, and the new, higher-priority process takes control of the CPU.


  1. Suitability for Important Processes: Priority scheduling is particularly effective in scenarios where certain tasks must be given more importance due to their nature (e.g., real-time constraints, urgency).

  2. Control and Flexibility: It allows the system to have control over process execution order based on the requirements, such as giving preference to shorter tasks or system-critical tasks.


  1. Starvation of Low-Priority Processes: A major drawback is the potential starvation of low-priority processes. If high-priority processes frequently arrive, lower-priority processes might be delayed indefinitely.

  2. Priority Assignment Complexity: Determining the correct priorities for processes can be challenging, especially in dynamic environments where process requirements can change over time.

  3. Priority Inversion: In situations where lower-priority processes hold resources needed by higher-priority ones, the system might experience a 'priority inversion', where high-priority processes are indirectly blocked by lower-priority ones.


  • Implementation in Different Systems: Priority scheduling is widely used in real-time operating systems where certain tasks must meet specific timing constraints. However, it requires careful design to prevent common problems like starvation and priority inversion.

  • Dynamic Priority Adjustment: Some systems implement dynamic priority adjustment to mitigate starvation. For example, the priorities of waiting processes may be gradually increased over time to ensure they eventually get CPU time.

  • Combination with Other Algorithms: Priority scheduling is often used in combination with other algorithms. For instance, within the same priority level, processes might be scheduled using Round-Robin or SJF.

Round Robin (RR) scheduling is a widely used CPU scheduling algorithm, particularly in time-sharing systems. It's designed to provide a fair allocation of CPU time to all processes, ensuring that no single process monopolizes the CPU.

  • Fixed Time Quantum: In RR scheduling, each process in the ready queue is assigned a fixed time slot, known as a time quantum or time slice. This is the maximum amount of time a process can run before it is interrupted and the CPU is handed over to the next process in the queue.

  • Circular Queue: The ready queue is treated as a circular queue. The CPU scheduler goes through the queue, allocating the CPU to each process for a time period up to one quantum. After a process uses up its quantum, it's placed at the back of the queue, and the scheduler selects the next process in the queue.

Significance of Time Quantum

  • Too Large Quantum: If the time quantum is set too large, RR scheduling essentially degenerates into FCFS scheduling, where processes are run in the order they arrive without preemption. This can lead to longer waiting times for shorter tasks.

  • Too Small Quantum: Conversely, if the time quantum is too small, the system spends a significant amount of time performing context switches. Frequent context switching can lead to lower CPU efficiency, as more time is spent switching between processes rather than executing them.


  1. Fairness: One of the key benefits of RR is its fairness. Every process gets an equal share of the CPU, avoiding situations where a particular process is starved of CPU time.

  2. Responsiveness: RR is suitable for time-sharing environments because it allows multiple processes to progress, which can be important for interactive systems where response time is a critical factor.

  3. Simplicity: The algorithm is relatively simple and straightforward to implement.

  4. Balance Between Throughput and Response Time: RR offers a good compromise between throughput and response time, making it suitable for a wide range of applications.


  1. Performance Dependency on Time Quantum: The biggest challenge in RR scheduling is setting the optimal time quantum. An inappropriate quantum size can significantly impact system performance.

  2. Longer Average Waiting Time: Compared to algorithms like Shortest Job First (SJF), the average waiting time under RR can be longer, especially if the time quantum is not optimally set.

  3. Context Switching Overhead: If the time quantum is too small, the overhead of context switching can degrade overall system performance.


  • Tuning Time Quantum: Finding the right balance for the time quantum is crucial. It often requires tuning based on the specific workload and system characteristics. A medium-sized quantum is generally a good compromise.

  • Variants and Improvements: Variants of RR, such as Dynamic Round Robin, attempt to adjust the time quantum dynamically based on system load or other metrics, aiming to optimize performance.

  • Use in Real Systems: RR is commonly used in operating systems, especially those designed for time-sharing. It's often seen as a practical choice for systems where fairness and responsiveness are more important than minimizing the average waiting time.

Highest Response Ratio Next (HRRN) is a non-preemptive CPU scheduling algorithm that aims to overcome some of the limitations of algorithms like Shortest Job First (SJF) and First-Come, First-Served (FCFS). HRRN introduces a more balanced approach by considering both the waiting time and the estimated burst time of processes.

  • Response Ratio Calculation: In HRRN, the scheduler calculates a "response ratio" for each process in the ready queue. The response ratio is determined by the formula: [ \text{Response Ratio} = \frac{\text{Waiting Time} + \text{Estimated Burst Time}}{\text{Estimated Burst Time}} ] Here, the waiting time is the time a process has spent in the ready queue, and the estimated burst time is the predicted time the process will take on the CPU.

  • Process Selection: The process with the highest response ratio is selected for execution next. As a process waits longer in the ready queue, its waiting time increases, which in turn increases its response ratio, making it more likely to be chosen.


  1. Reduced Starvation: By factoring in waiting time, HRRN reduces the likelihood of starvation for longer processes, a common problem in SJF.

  2. Balanced Approach: HRRN provides a balance between servicing short and long processes. Short processes are handled efficiently, and long processes are less likely to be starved.

  3. Dynamic Prioritization: The response ratio is recalculated each time a decision is to be made, allowing for dynamic adjustments in prioritization based on current wait times.


  1. Need for Burst Time Knowledge: Like SJF, HRRN requires an estimate of the next CPU burst time for each process, which can be difficult to predict accurately.

  2. Implementation Complexity: Calculating and continually updating response ratios for all processes in the ready queue makes HRRN more complex to implement compared to simpler algorithms like FCFS or RR.

  3. Possibly Longer Short-Term Wait for Short Processes: While it mitigates long-term starvation, HRRN can cause short jobs to wait longer than they would under pure SJF, especially if they enter the queue behind processes with already high response ratios.


  • Fairness and Efficiency: HRRN is considered fairer than SJF and more efficient than FCFS in terms of overall average waiting time. It tries to strike a balance between serving short jobs quickly and not neglecting long jobs.

  • Suitability: HRRN is well-suited for batch processing environments where the primary goal is to optimize overall throughput and fairness, rather than minimizing response time for interactive systems.

  • Estimation of Burst Time: The accuracy of burst time prediction is crucial for HRRN's effectiveness. Systems implementing HRRN often rely on historical data and sophisticated algorithms for burst time estimation.

Multilevel Queue Scheduling is a sophisticated CPU scheduling approach designed to cater to systems where processes can be distinctly categorized, often based on their priority or type. This method uses multiple queues, each with its own scheduling algorithm, to manage different classes of processes.

  • Multiple Queues: The fundamental characteristic of Multilevel Queue Scheduling is the division of the ready queue into several separate queues. Each of these queues corresponds to a specific group of processes, typically based on criteria like process priority, memory requirements, process type (system process, interactive user process, batch process, etc.), or CPU burst behavior (CPU-bound vs. I/O-bound).

  • Queue-Specific Scheduling: Each queue can have its own scheduling algorithm, tailored to the specific needs of the process type it serves. For instance, a queue for system processes might use a Round Robin algorithm for fairness, while a queue for CPU-bound processes might use Shortest Job First for efficiency.

  • Fixed Priorities: Usually, each queue is assigned a fixed priority, with the scheduler serving higher-priority queues before lower-priority ones. Within each queue, the scheduling algorithm specific to that queue is applied to determine the order of process execution.


  1. Flexibility and Customization: By categorizing processes into different queues with distinct scheduling needs, Multilevel Queue Scheduling allows for more tailored and efficient process management.

  2. Efficient Handling of Different Process Types: The system can optimize CPU time for different types of processes, such as giving preference to system processes over user processes or prioritizing interactive tasks over batch jobs.

  3. Priority Management: It inherently supports priority scheduling by segregating processes into different queues based on their priority level.


  1. Complex Process Migration: Moving processes between different queues can be complex and may require additional management logic, especially if process characteristics change over time (e.g., a process becoming more I/O-bound).

  2. Starvation of Lower-Priority Queues: Processes in lower-priority queues may suffer from starvation, especially if higher-priority queues are constantly busy.

  3. Fixed Priority Limitations: The fixed priorities of queues can lead to inflexibility, where certain processes are always favored over others, regardless of their current importance or urgency.


  • Queue Management: Effective implementation of Multilevel Queue Scheduling requires careful consideration of how queues are defined and how processes are classified into these queues. Misclassification can lead to inefficiencies or unfair process treatment.

  • Use in Complex Systems: This scheduling approach is particularly useful in complex systems where processes can be clearly categorized into different groups with distinct characteristics and requirements.

  • Combining with Other Algorithms: Multilevel Queue Scheduling is often used in conjunction with other scheduling algorithms to optimize CPU utilization and ensure fairness within each queue.

Multilevel Feedback Queue Scheduling is an advanced CPU scheduling algorithm that builds upon the concept of Multilevel Queue Scheduling. It introduces the dynamic element of allowing processes to move between different queues based on their evolving behavior and requirements. This flexibility makes it one of the most sophisticated and adaptable scheduling algorithms used in modern operating systems.

  • Dynamic Queue Allocation: In Multilevel Feedback Queue Scheduling, multiple queues are used, each with different scheduling criteria (like in Multilevel Queue Scheduling). However, unlike the standard multilevel queue system, processes are not permanently assigned to a specific queue. Instead, they can move between queues based on certain criteria, typically related to their observed CPU burst behavior.

  • Behavior-Based Scheduling: The primary idea is to dynamically adjust the priority of a process based on its actual CPU usage and I/O behavior. For example, a process that uses too much CPU time might be moved to a lower-priority queue, while a process that yields the CPU frequently (indicating I/O-bound behavior) could be moved to a higher-priority queue.

  • Queue Parameters: Each queue might have different scheduling algorithms and parameters, such as time quantum length. The topmost queue (highest priority) might have the smallest time quantum, encouraging quick turnaround times for interactive processes.


  1. High Flexibility and Responsiveness: This method adapts to the behavior of processes, allocating resources in a manner that can efficiently handle both CPU-bound and I/O-bound processes.

  2. Reduces Starvation: By adjusting the priorities and allowing processes to move to different queues, it reduces the likelihood of starvation for lower-priority processes.

  3. Balanced Performance: It strikes a balance between favoring short processes (for responsiveness) and ensuring that long processes eventually complete, providing a good mix of turnaround time and throughput.


  1. Implementation Complexity: Multilevel Feedback Queue Scheduling is complex to implement. It requires sophisticated mechanisms to track process behavior and decide when and how to move processes between queues.

  2. Configuration and Tuning: The effectiveness of this scheduling heavily depends on how well the queues are configured, including the determination of queue parameters, time quanta, and the criteria for moving processes between queues.

  3. Potential for Overhead: The dynamic nature of the algorithm, with processes moving between queues, can introduce overhead, especially if process reclassification happens frequently.


  • Customization for System Needs: The algorithm allows for considerable customization to tailor the system's behavior based on specific workload requirements.

  • Use in Real Systems: It is particularly suited to general-purpose operating systems where process workloads are unpredictable and varied.

  • Optimization Challenges: Finding the optimal configuration can be challenging and often requires empirical tuning and adjustments based on the system's workload.