0% found this document useful (0 votes)
21 views8 pages

CPU Scheduling Methods and Criteria

CPU scheduling is a critical function of operating systems that determines which processes run on the CPU and in what order, impacting system performance. Various algorithms exist, including First Come First Serve, Shortest Job First, and Round Robin, each with distinct advantages and disadvantages based on criteria like CPU utilization, throughput, and waiting time. The choice of scheduling algorithm depends on specific system needs and can significantly affect process execution efficiency.

Uploaded by

jaisingh2744
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views8 pages

CPU Scheduling Methods and Criteria

CPU scheduling is a critical function of operating systems that determines which processes run on the CPU and in what order, impacting system performance. Various algorithms exist, including First Come First Serve, Shortest Job First, and Round Robin, each with distinct advantages and disadvantages based on criteria like CPU utilization, throughput, and waiting time. The choice of scheduling algorithm depends on specific system needs and can significantly affect process execution efficiency.

Uploaded by

jaisingh2744
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIT 2

CPU Scheduling
CPU scheduling is a method process or task that the CPU will run at any given moment. It
is an essential part of modern operating systems as it enables multiple processes to run
at the same time on the same processor. In short, the CPU scheduler decides the order
and priority of the processes to run and allocates the CPU time based on various
parameters such as CPU usage, throughput, turnaround, waiting time, and response time.

CPU scheduling is essential for the system’s performance and ensures that processes are
executed correctly and on time. Different CPU scheduling algorithms have other
properties and the choice of a particular algorithm depends on various factors. Many
criteria have been suggested for comparing CPU scheduling algorithms.

Criteria of CPU Scheduling


CPU Scheduling has several criteria. Some of them are mentioned below.

CPU utilization

The main objective of any CPU scheduling algorithm is to keep the CPU as busy as
possible. Theoretically, CPU utilization can range from 0 to 100 but in a real-time system,
it varies from 40 to 90 percent depending on the load upon the system.

Throughput

A measure of the work done by the CPU is the number of processes being executed and
completed per unit of time. This is called throughput.

Turnaround Time

For a particular process, an important criterion is how long it takes to execute that
process. The time elapsed from the time of submission of a process to the time of
completion is known as the turnaround time. Turn-around time is the sum of times spent
waiting to get into memory, waiting in the ready queue, executing in CPU, and waiting for
I/O.
Turn Around Time = Completion Time - Arrival Time.

Waiting Time
A scheduling algorithm does not affect the time required to complete the process once it
starts execution. It only affects the waiting time of a process i.e. time spent by a process
waiting in the ready queue.
Waiting Time = Turnaround Time - Burst Time.

Response Time

In an interactive system, turn-around time is not the best criterion. A process may produce
some output fairly early and continue computing new results while previous results are
being output to the user. Thus another criterion is the time taken from submission of the
process of the request until the first response is produced. This measure is called
response time.
Response Time = CPU Allocation Time(when the CPU was allocated for the
first) - Arrival Time

Completion Time

The completion time is the time when the process stops executing, which means that the
process has completed its burst time and is completely executed.

Priority

If the operating system assigns priorities to processes, the scheduling mechanism should
favor the higher-priority processes.

What are the different terminologies to take care of in any


CPU Scheduling algorithm?
●​ Arrival Time: Time at which the process arrives in the ready queue.

●​ Completion Time: Time at which process completes its execution.

●​ Burst Time: Time required by a process for CPU execution.

●​ Turn Around Time: Time Difference between completion time and arrival time.

Turn Around Time = Completion Time – Arrival Time

●​ Waiting Time(W.T): Time Difference between turn around time and burst time.
Waiting Time = Turn Around Time – Burst Time

There are mainly two types of scheduling methods:

●​ Preemptive Scheduling: Preemptive scheduling is used when a process switches

from running state to ready state or from the waiting state to the ready state.

●​ Non-Preemptive Scheduling: Non-Preemptive scheduling is used when a

process terminates , or when a process switches from running state to waiting

state.

1. First Come First Serve:

FCFS considered to be the simplest of all operating system scheduling algorithms. First
come first serve scheduling algorithm states that the process that requests the CPU first
is allocated the CPU first and is implemented by using FIFO queue.

Characteristics of FCFS:

●​ FCFS supports non-preemptive and preemptive CPU scheduling algorithms.

●​ Tasks are always executed on a First-come, First-serve concept.

●​ FCFS is easy to implement and use.

●​ This algorithm is not much efficient in performance, and the wait time is quite

high.

Disadvantages of FCFS:

●​ FCFS suffers from Convoy effect.

●​ The average waiting time is much higher than the other algorithms.

●​ FCFS is very simple and easy to implement and hence not much efficient.
●​

Shortest Job First(SJF):

Shortest job first (SJF) is a scheduling process that selects the waiting process with the
smallest execution time to execute next. This scheduling method may or may not be
preemptive. Significantly reduces the average waiting time for other processes waiting to
be executed. The full form of SJF is Shortest Job First.

Advantages of Shortest Job first:


●​ As SJF reduces the average waiting time thus, it is better than the first come first
serve scheduling algorithm.
●​ SJF is generally used for long term scheduling

Disadvantages of SJF:
●​ One of the demerit SJF has is starvation.
●​ Many times it becomes complicated to predict the length of the upcoming CPU
request
. Round robin:

Round Robin is a CPU scheduling algorithm where each process is cyclically assigned a
fixed time slot. It is the preemptive version of First come First Serve CPU Scheduling
algorithm. Round Robin CPU Algorithm generally focuses on Time Sharing technique.

Characteristics of Round robin:

●​ It’s simple, easy to use, and starvation-free as all processes get the balanced

CPU allocation.

●​ One of the most widely used methods in CPU scheduling as a core.

●​ It is considered preemptive as the processes are given to the CPU for a very

limited time.

●​ Round robin seems to be fair as every process gets an equal share of CPU.

●​ The newly created process is added to the end of the ready queue.
Multiple Queue Scheduling:

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 a background (batch) process. These two classes have different scheduling

needs. For this kind of situation Multilevel Queue Scheduling is used.


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

●​ System Processes: The CPU itself has its process to run, generally termed as

System Process.

●​ Interactive Processes: An Interactive Process is a type of process in which there

should be the same type of interaction.

●​ Batch Processes: Batch processing is generally a technique in the Operating

system that collects the programs and data together in the form of a batch

before the processing starts.

Advantages of multilevel queue scheduling:

●​ The main merit of the multilevel queue is that it has a low scheduling overhead.

Disadvantages of multilevel queue scheduling:

●​ Starvation problem

●​ It is inflexible in nature

Common questions

Powered by AI

A priority-based scheduling system impacts process management by organizing CPU time allocation based on process priority levels, which ensures critical and high-importance tasks are processed before others. This setup provides significant advantages in environments where specific tasks require precedence due to their urgency or importance, enhancing overall efficiency and responsiveness for critical processes. However, this approach also introduces potential issues of starvation, where lower-priority processes might be indefinitely delayed if high-priority tasks persist. Balancing priorities and introducing aging techniques, where low-priority processes gradually gain higher priority over time, can mitigate this issue but requires careful implementation to avoid unfair resource allocation .

Turnaround Time and Waiting Time are both scheduling criteria reflecting different aspects of process management. Turnaround Time is the total time taken for a process from its submission to its completion, calculated as Completion Time minus Arrival Time. It reflects the total time a process spends in the system, which includes waiting, executing, and I/O time. Waiting Time, on the other hand, isolates the time a process spends in the queue waiting for CPU access, computed as Turnaround Time minus Burst Time. This metric specifically indicates how long a process waits before getting executed, thus highlighting scheduling efficiency concerning prompt access to CPU resources .

'Starvation' in CPU scheduling refers to a situation where a process is perpetually overlooked by the scheduler, delaying its execution indefinitely while other processes are repeatedly prioritized. Scheduling algorithms like Shortest Job First (SJF) and Priority Scheduling are more prone to starvation. In SJF, longer processes may be consistently postponed if short processes continue to arrive. Similarly, in Priority Scheduling, low-priority processes may face indefinite delays if higher-priority processes dominate CPU time. These scenarios occur because both algorithms prioritize specific process attributes—shortness of job duration and priority, respectively—without guaranteeing equal opportunity for process execution .

Preemptive scheduling allows the current running process to be paused and moved to the ready state to allocate CPU to another process, typically when a higher-priority process arrives or the current process needs I/O. Non-preemptive scheduling only switches processes when the current process completes or moves to a waiting state, meaning it holds the CPU until done unless it blocks itself with I/O operations. This distinction is crucial as preemptive scheduling can efficiently manage processes by rapidly responding to critical tasks, while non-preemptive is simpler but may lead to inefficient CPU use and delays for short tasks if long tasks monopolize the CPU .

The Round Robin scheduling algorithm is advantageous as it is simple, easy to implement, and ensures starvation-free operation, providing balanced CPU allocation to all processes. It is widely used for its fairness, as each process receives an equal time slot cyclically. However, one disadvantage is that processes might not complete within their time slots, leading to frequent context switching, which can reduce overall efficiency. Despite this, its time-sharing nature is suitable for systems aiming for equitable resource distribution among processes .

CPU utilization refers to the extent to which the CPU is actively working, ideally ranging from 0 to 100%. In real-time systems, it typically varies from 40% to 90% because of fluctuating workloads and system demands. Factors like I/O operations, process switching, and system interruptions can prevent the CPU from maintaining maximum output. Theoretical maximum utilization would mean no idle time, but in practical scenarios, achieving this is unrealistic due to the dynamic and varied nature of tasks that require occasional CPU downtime for optimal system performance and to handle varying workloads efficiently .

Shortest Job First (SJF) is more efficient than First Come First Serve (FCFS) in terms of average waiting time because it selects the process with the shortest execution time, thereby reducing the wait time for subsequent processes. This efficiency stems from its ability to prioritize smaller, quicker tasks, improving throughput and minimizing the total waiting time in the queue. However, SJF has potential downsides, including the risk of starvation for longer processes, which may continually be delayed if short tasks keep entering the queue. Additionally, accurately predicting the length of upcoming processes can be challenging, limiting SJF's practical application .

The primary criteria in CPU scheduling include CPU utilization, throughput, turnaround time, waiting time, and response time. CPU utilization refers to keeping the CPU as busy as possible, ideally ranging between 40% to 90% in active systems. Throughput measures the number of processes completed per unit time, indicating system productivity. Turnaround time is the duration from submission to completion of a process, while waiting time is the period a process spends in the ready queue. Response time is crucial in interactive systems, measuring the time from submission to the first response from the CPU. These criteria are vital for system performance as they collectively ensure efficient CPU load balancing, enhance user satisfaction by minimizing wait times, and optimize resource use .

The 'convoy effect' in CPU scheduling occurs when a longer process holds the CPU, causing a queue of shorter processes to wait, thereby degrading system performance. This situation is most prominent in the First Come First Serve (FCFS) scheduling algorithm, where processes are queued in the order of their arrival. If a long process reaches the CPU first, all subsequent shorter processes must wait until the lengthy task is completed, resulting in increased waiting and response times for those shorter tasks. Hence, FCFS's non-preemptive nature makes it particularly susceptible to the convoy effect .

Multilevel queue scheduling divides processes in the ready queue into several separate categories, each with its own queue and scheduling requirements, such as foreground (interactive processes) and background (batch processes). This system allows for tailored scheduling by assigning different priorities and resources according to process class needs. The advantage of this method is its low scheduling overhead and ability to handle diverse process requirements efficiently. However, a significant drawback is its inflexibility, potentially leading to starvation if lower-priority queues are frequently overshadowed by higher-priority tasks, as each category’s needs can differ substantially .

You might also like