What Are the Criteria of CPU Scheduling Algorithms
What Are the Criteria of CPU Scheduling Algorithms
CPU scheduling algorithms are judged based on how fast, fair, and efficient they are in
giving CPU time to processes.
Explanation
Think of CPU scheduling like a teacher calling students one by one to answer questions in class.
The goal is to make sure:
CPU is always busy – Like the teacher is always asking questions, not sitting idle. (This
is CPU Utilization.)
Students don’t wait too long – So no one is ignored for a long time. (This is Waiting
Time.)
Everyone gets their turn quickly – So students get to speak soon after raising their
hands. (This is Turnaround Time.)
Short answers go quickly – So quick students aren’t delayed by long ones. (This is
Response Time and Throughput.)
It's fair to everyone – No student feels left out. (This is Fairness.)
Preemptive Scheduling is like a teacher who can stop a student mid-answer and ask
another student if their answer is more urgent.
Non-Preemptive Scheduling is like a teacher who lets one student finish speaking
completely before calling the next one.
“Hey, I know you're speaking, but this other student has something super quick or more
important to say—so I’ll pause you and let them speak first.”
This is Preemptive – the CPU (teacher) can stop a running process (student) and switch to
another one that seems more urgent or quicker.
It’s useful when some tasks need quick response (like playing music or responding to a key
press).
Real-life example: Someone at a fast-food counter pauses your order because a delivery person
just needs to pick up one ready item. Quick and efficient!
This is Non-Preemptive – once a task starts, the CPU won’t interrupt it. It’ll only move on when
the task is fully done.
Real-life example: You're at a salon, and once your haircut starts, the barber won’t stop halfway
to attend someone else, no matter how urgent.
There are several CPU scheduling algorithms used to decide the order in which processes get to
use the CPU. Each one has a different strategy depending on speed, fairness, and priority.
🔹 Meaning: The process with the shortest burst time (execution time) gets the CPU
first.
🔹 Type: Can be preemptive or non-preemptive
🔹 Advantage: Gives minimum average waiting time.
🔹 Challenge: It needs to know how long a process will take (which is hard to guess).
Priority Scheduling
🔹 Meaning: Every process is given a priority number, and the CPU chooses the one
with the highest priority.
🔹 Type: Can be preemptive or non-preemptive
🔹 Problem: Low priority processes might starve (never get CPU).
🔹 Fix: Aging (gradually increase priority of waiting processes).
🔹 Meaning: Processes are divided into multiple groups/queues based on priority (like
system processes, user processes, etc.)
🔹 Each queue has its own scheduling algorithm.
🔹 Fixed priority between queues (e.g., system queue runs before user queue).
Example:
P1 0 ms 5 ms
P2 1 ms 3 ms
P3 2 ms 1 ms
Then, the CPU will serve them in the order: P1 → P2 → P3, even though P3 is the shortest.
Advantages of FCFS:
SJF selects the process that has the shortest burst time (the time needed to complete the
job) and executes it first.
It gives priority to short processes to reduce the total waiting time.
It can be of two types:
1. Non-preemptive SJF – Once a process starts, it runs until it finishes.
2. Preemptive SJF (also called Shortest Remaining Time First) – If a new process
arrives with a shorter burst time, it interrupts the current one.
Example:
P1 0 ms 6 ms
P2 1 ms 2 ms
P3 2 ms 1 ms
SJF will schedule them in this order: P3 → P2 → P1 (because P3 is shortest, then P2, then P1).
Advantages of SJF: