0% found this document useful (0 votes)
4 views

What Are the Criteria of CPU Scheduling Algorithms

The document discusses CPU scheduling algorithms, focusing on criteria such as CPU utilization, waiting time, turnaround time, response time, and fairness. It explains preemptive and non-preemptive scheduling, detailing various algorithms including First-Come, First-Served (FCFS), Shortest Job First (SJF), Priority Scheduling, Round Robin, and Multilevel Queue Scheduling, along with their advantages and disadvantages. The document emphasizes the importance of choosing the right scheduling algorithm based on the specific needs of the system.

Uploaded by

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

What Are the Criteria of CPU Scheduling Algorithms

The document discusses CPU scheduling algorithms, focusing on criteria such as CPU utilization, waiting time, turnaround time, response time, and fairness. It explains preemptive and non-preemptive scheduling, detailing various algorithms including First-Come, First-Served (FCFS), Shortest Job First (SJF), Priority Scheduling, Round Robin, and Multilevel Queue Scheduling, along with their advantages and disadvantages. The document emphasizes the importance of choosing the right scheduling algorithm based on the specific needs of the system.

Uploaded by

worldandinfo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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

2. Explain the preemptive and non-premptive scheduling algorithm.

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

Preemptive Scheduling (Interrupting Mode)

In this mode, the teacher says:

“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!

Non-Preemptive Scheduling (Polite Mode)

Here, the teacher says:


“You started speaking, so take your time and finish. I’ll wait before calling someone else.”

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.

Feature Preemptive Non-Preemptive


Can be interrupted? Yes No
Who gets CPU next? Most urgent/shortest task Next in line (wait your turn)
Example situation Emergency room in hospital People in line at a bank

3. Write the various CPU Scheduling algorithms.

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.

First-Come, First-Served (FCFS)

 🔹 Meaning: The process that comes first will be served first.


 🔹 Example: Like standing in a queue—whoever comes first gets the service first.
 🔹 Type: Non-preemptive
 🔹 Downside: Long jobs can delay shorter ones (called “convoy effect”).

Shortest Job First (SJF)

 🔹 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).

Round Robin (RR)


 🔹 Meaning: Each process gets a fixed time slice (quantum) to run. After its time is up, it
goes to the back of the line.
 🔹 Type: Preemptive
 🔹 Best for: Time-sharing systems (like multitasking in operating systems).
 🔹 Fairness: Every process gets an equal chance.

Multilevel Queue Scheduling

 🔹 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).

4. Discuss the FCFS(First Come First Serve) scheduling algorithm. Write


its advantage and disadvantage.

FCFS (First Come First Serve) Scheduling Algorithm:

 FCFS is the simplest CPU scheduling algorithm.


 It works just like a queue in a shop:
The process that arrives first is executed first, and the next one waits until the current
process is done.
 It is a non-preemptive algorithm, which means once a process starts, it runs till
completion without interruption.

Example:

If 3 processes come in this order:

Process Arrival Time Burst Time

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:

1. Simple to understand and implement


o Works just like a real-world queue.
2. Fair (in arrival order)
o Every process gets a turn based on when it arrived.
Disadvantages of FCFS:

1. Poor performance if long process comes first


o Called the Convoy Effect – one big task delays all small ones behind it.
2. Not suitable for time-sharing systems
o It can make the system slow and unresponsive.
3. Long waiting time for short tasks
o Shorter jobs may suffer even if they arrive early.

5. Discuss the SJF(Shortest Job First) scheduling algorithm. Write its


advantage and disadvantage.

SJF (Shortest Job First) Scheduling Algorithm:

 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:

Suppose these are the processes:

Process Arrival Time Burst Time

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:

1. Minimum average waiting time


o It's the most efficient in terms of waiting time compared to other algorithms.
2. Good for batch systems
o Works well when all jobs are known in advance (like in offline processing).
Disadvantages of SJF:

1. Difficult to predict burst time


o The CPU doesn’t always know how long a process will take.
2. Risk of starvation
o Long processes might never get the CPU if short ones keep arriving.
3. Not suitable for real-time systems
o Delays in deciding which job is shortest can cause issues.

You might also like