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

CPU Scheduling Algorithms

This document compares two CPU scheduling algorithms: First Come First Serve (FCFS) and Shortest Job First (SJF). FCFS is simple and fair but can lead to poor average waiting times, while SJF aims to minimize waiting times by prioritizing shorter jobs. Both algorithms are non-preemptive and utilize similar formulas for calculating waiting and turnaround times.

Uploaded by

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

CPU Scheduling Algorithms

This document compares two CPU scheduling algorithms: First Come First Serve (FCFS) and Shortest Job First (SJF). FCFS is simple and fair but can lead to poor average waiting times, while SJF aims to minimize waiting times by prioritizing shorter jobs. Both algorithms are non-preemptive and utilize similar formulas for calculating waiting and turnaround times.

Uploaded by

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

CPU Scheduling Algorithms

FCFS vs SJF - Program


Explanation and Comparison
Welcome to our presentation on CPU scheduling. We will explore how
different algorithms manage processor time. Our focus today is on First
Come First Serve and Shortest Job First.
Introduction to CPU Scheduling
Order of Access
CPU scheduling determines the sequence processes access the CPU.

Boosted Performance
Efficient scheduling improves overall system performance.

Reduced Waiting
It minimizes waiting time for processes.

CPU Utilization
Increases the overall CPU utilization rate.

CPU scheduling is vital for system efficiency. It manages how processes share the CPU.
Today, we compare FCFS and SJF, both non-preemptive algorithms.
FCFS - Overview
Simplest Algorithm
First Come First Serve (FCFS) is very straightforward.

Arrival Order
Processes execute in their arrival order.

Non-Preemptive
Once started, a process runs to completion.

FCFS operates like a simple queue. The first process to arrive is the first to be
served. It's easy to understand but has specific implications.
FCFS - Key Logic & Formulas
Waiting Time Turnaround Time
Calculation Calculation
WT(n) = WT(n-1) + BT(n-1) TAT(n) = WT(n) + BT(n)

Average Times
Average Waiting Time = Total WT / Number of Processes

Average Turnaround Time = Total TAT / Number of Processes

These formulas are fundamental for evaluating FCFS. They help quantify
performance. Understanding these metrics is crucial for comparison.
FCFS - Example

5 3 8
P1 Burst Time P2 Burst Time P3 Burst Time
P1 has a burst time of 5 units. P2 has a burst time of 3 units. P3 has a burst time of 8 units.

With P1=5, P2=3, P3=8:

• Waiting Times: P1 = 0, P2 = 5, P3 = 8
• Turnaround Times: P1 = 5, P2 = 8, P3 = 16

Averages:

• Avg WT = 4.33
• Avg TAT = 9.67
FCFS - Pros and Cons
Advantages Disadvantages

• Simple to implement. • Poor average waiting time.


• Fair to all processes. • Suffers from convoy effect.
• No starvation. • Short jobs wait for long ones.

FCFS's simplicity comes with trade-offs. While fair, its performance can be suboptimal. The "convoy effect" is a significant drawback.
SJF - Overview

Minimize Waiting
Aims to minimize average waiting time.

Shortest Burst Time


SJF selects process with the shortest
burst time.
Non-Preemptive
Once chosen, a process runs to
completion.

SJF prioritizes efficiency by serving shorter jobs first. This approach often leads to better overall performance metrics. It's a key
optimization strategy.
SJF - Key Logic & Sorting
Sort by Burst Time
Processes are sorted by their burst time in ascending order.

Waiting Time Formula


WT(n) = WT(n-1) + BT(n-1)

Turnaround Time Formula


TAT(n) = WT(n) + BT(n)

The core of SJF is its sorting logic. This ensures optimal process selection.
The waiting and turnaround time formulas remain consistent with FCFS,
applied after sorting.

You might also like