0% found this document useful (0 votes)
4 views2 pages

Cpu Scheduling

CPU scheduling is the method by which the CPU is allocated to processes in a multi-programming environment, with the CPU scheduler making decisions to maximize utilization and minimize waiting times. Key algorithms include First-Come, First-Served (FCFS), which is simple but can lead to long waiting times, and Shortest Job First (SJF), which optimizes average waiting time but can cause starvation for longer processes. Each algorithm has its own advantages and disadvantages, impacting overall system performance.

Uploaded by

bhanupartap1125
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)
4 views2 pages

Cpu Scheduling

CPU scheduling is the method by which the CPU is allocated to processes in a multi-programming environment, with the CPU scheduler making decisions to maximize utilization and minimize waiting times. Key algorithms include First-Come, First-Served (FCFS), which is simple but can lead to long waiting times, and Shortest Job First (SJF), which optimizes average waiting time but can cause starvation for longer processes. Each algorithm has its own advantages and disadvantages, impacting overall system performance.

Uploaded by

bhanupartap1125
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
You are on page 1/ 2

What is CPU Scheduling?

CPU Scheduling is the process by which the CPU is assigned to different processes in a multi-
programming environment. When multiple processes are in the ready queue, the operating system
must choose one to execute next. The part of the OS that makes this decision is called the CPU
scheduler.
The goal of CPU scheduling is to maximize CPU utilization and system throughput while
minimizing waiting time, turnaround time, and response time.

Types of CPU Scheduling Algorithms


There are several types, but two important ones are explained below:

1. First-Come, First-Served (FCFS) Scheduling


Definition:
FCFS is the simplest CPU scheduling algorithm. The process that arrives first is served first, like
a queue in a supermarket.

Characteristics:
 Non-preemptive: Once a process starts executing, it runs till completion.
 Based on arrival time.

Advantages:
 Simple and easy to implement.
 Fair (in the sense that jobs are processed in order of arrival).

Disadvantages:
 Can lead to long waiting times, especially if a long process comes before a short one (called
the convoy effect).
 Poor average waiting time.

Example:
Process Arrival Time Burst Time
P1 0 5
P2 1 3
P3 2 8
Execution Order: P1 → P2 → P3
Waiting Times:
P1 = 0,
P2 = 5 - 1 = 4,
P3 = 5 + 3 - 2 = 6
Average Waiting Time = (0 + 4 + 6)/3 = 3.33 ms

2. Shortest Job First (SJF) Scheduling


Definition:
In SJF, the process with the smallest CPU burst time is selected next.

Types:
 Non-preemptive SJF: Once a process starts, it completes.
 Preemptive SJF (also called Shortest Remaining Time First - SRTF): A new process can
preempt if it has a shorter burst time.

Advantages:
 Optimal in terms of average waiting time for non-preemptive version.
 Efficient use of CPU.

Disadvantages:
 Difficult to know the burst time in advance.
 Can lead to starvation of longer processes.

Example (Non-preemptive SJF):


Process Arrival Time Burst Time
P1 0 8
P2 1 4
P3 2 2
P4 3 1
Execution Order: P1 → P4 → P3 → P2
(based on smallest burst time among available processes)
Waiting Times:
P1 = 0,
P4 = 8 - 3 = 5,
P3 = 8 + 1 - 2 = 7,
P2 = 8 + 1 + 2 - 1 = 10
Average Waiting Time = (0 + 5 + 7 + 10)/4 = 5.5 ms

You might also like