0% found this document useful (0 votes)
42 views9 pages

Scheduling

The document discusses common scheduling algorithms used in operating systems including First Come First Serve (FCFS), Shortest Job First (SJF), and priority-based scheduling. FCFS executes jobs in the order they arrive but does not guarantee good response times. SJF selects the process with the shortest estimated CPU burst time to run next, in either a non-preemptive or preemptive version. Priority-based scheduling runs processes with the highest priority first based on assigned priorities that can consider memory, time, or other resource needs. Metrics like waiting time, turnaround time, and throughput are used to analyze scheduling algorithm performance.

Uploaded by

YashaswiKashyap
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)
42 views9 pages

Scheduling

The document discusses common scheduling algorithms used in operating systems including First Come First Serve (FCFS), Shortest Job First (SJF), and priority-based scheduling. FCFS executes jobs in the order they arrive but does not guarantee good response times. SJF selects the process with the shortest estimated CPU burst time to run next, in either a non-preemptive or preemptive version. Priority-based scheduling runs processes with the highest priority first based on assigned priorities that can consider memory, time, or other resource needs. Metrics like waiting time, turnaround time, and throughput are used to analyze scheduling algorithm performance.

Uploaded by

YashaswiKashyap
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/ 9

SCHEDULING

ALGORITHMS

COMMON TERMS
CPU Utilization The percentage of time that the CPU is
busy.
Throughput The number of processes completing in a
unit of time.
Turnaround time The length of time it takes to run a
process from initialization to termination, including all
the waiting time.
Waiting time The total amount of time that a process
is in the ready queue.
Response time The time between when a process is
ready to run and its next I/O request.

FCFS (First Come First Serve)


The scheduler executes jobs to complete in arrival order.
In early FCFS schedulers, the job did not relinquish the CPU even
when it was doing I/O (blocking process).
We will assume a FCFS scheduler that runs when processes are
blocked on I/O, but that is non-preemptive, i.e., the job keeps the
CPU until it blocks (say on an I/O device).
FCFS scheme is not useful in scheduling interactive users because it
cannot guarantee good response time.

Process Burst Time


P1 24
P2
P3

3
3

With FCFS, the process that requests the CPU first is allocated the CPU first
Case #1: Suppose that the processes arrive in the order: P1,P2,P3
P1
0

Waiting time for P1

= 0; P2

P2
24

P3
27

= 24; P3 = 27

Average waiting time: (0 + 24 + 27)/3 = 17


Average turn-around time: (24 + 27 + 30)/3 = 27

30

Shortest Job First (SJF)


The SJF algorithm associates with each process the length of its next CPU burst
When the CPU becomes available, it is assigned to the process that has the
smallest next CPU burst (in the case of matching bursts, FCFS is used)
Two schemes:
Non pre-emptive once the CPU is given to the process, it cannot be preempted until it completes its CPU burst
Pre-emptive if a new process arrives with a CPU burst length less than the
remaining time of the current executing process, pre-empt. This scheme is
know as the Shortest-Remaining-Time-First (SRTF).

Non Pre-emptive SJF


Process Arrival Time Burst Time
P1 0.0 6
P2 0.0 4
P3 0.0 1
P4 0.0 5

SJF (non-pre-emptive, simultaneous arrival)

Average waiting time = (0 + 1 + 5 + 10)/4 = 4


Average turn-around time = (1 + 5 + 10 + 16)/4 = 8

Pre-emptive SJF
Process
Arrival Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4

Burst Time

SJF (pre-emptive, varied arrival times)

Average waiting time


= ( [(0 0) + (11 - 2)] + [(2 2) + (5 4)] + (4 - 4) + (7 5) )/4
= 9 + 1 + 0 + 2)/4
=3
Average turn-around time
= (16 + 7 + 5 + 11)/4 = 9.75

Priority Based Scheduling


Each process is assigned a priority. Process with highest
priority is to be executed first and so on.
Processes with same priority are executed on first come
first serve basis.
Priority can be decided based on memory requirements,
time requirements or any other resource requirement.

Process Wait Time : Service Time - Arrival


Time
P0

9-0=9

P1

6-1=5

P2

14 - 2 = 12

P3

0-0=0

Wait time of each process is following


Average Wait Time: (9+5+12+0) / 4 = 6.5

You might also like