0% found this document useful (0 votes)
25 views30 pages

Lecture 5-Processor Scheduling

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)
25 views30 pages

Lecture 5-Processor Scheduling

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/ 30

Operati

ng
System
s: Chapter 9
Internal Uniprocessor
s and
Design Scheduling
Eighth Edition
Principl By William Stallings

es
Table 9.1

Types of Scheduling
rocessor Scheduling
 Aim is to assign processes to be executed by
the processor in a way that meets system
objectives, such as response time, throughput,
and processor efficiency
 Broken down into three separate functions:
medium
long term term short term
scheduling scheduli scheduling
ng
Long-Term Scheduler
 Determines which Creates
processes from
programs are admitted to the queue when it
the system for processing can, but must
decide:
 Controls the degree of
multiprogramming
when the
 the more processes operating system
that are created, which jobs to
can take on one
accept and turn
the smaller the or more
into processes
additional
percentage of time processes
that each process
can be executed
 may limit to provide
satisfactory service priority, expected
first come, first
execution time,
to the current set of served
I/O requirements
processes
Medium-Term
Scheduling
 Part of the swapping function
 Swapping-in decisions are based on the need to
manage the degree of multiprogramming
 considers the memory requirements of the
swapped-out processes
Short-Term Scheduling
 Known as the dispatcher
 Executes most frequently
 Makes the fine-grained decision of which process to
execute next
 Invoked when an event occurs that may lead to the
blocking of the current process or that may provide an
opportunity to preempt a currently running process in favor
Examples:
of another
• Clock interrupts
• I/O interrupts
• Operating system calls
• Signals (e.g., semaphores)
Short Term Scheduling
Criteria
 Main objective
is to allocate
processor time
to optimize
User-oriented System-oriented
certain aspects
criteria criteria
of system
• relate to the behavior • focus in on effective
behavior
of the system as and efficient
perceived by the utilization of the
 A set of criteria individual user or processor (rate at
is needed to process (such as which processes are
evaluate the response time in an completed)
interactive system) • generally of minor
scheduling • important on virtually importance on single-
policy all systems user systems
Short-Term Scheduling
Criteria: Performance
examples: example:
• response Criteria • predictabili
time can be
classified ty
• throughput
into:

Non-performance
Performance-related
related

quantitati easily hard to


qualitative
ve measured measure
Table 9.2

Scheduling Criteria

(Table can be found on page 403 in


textbook)
Table
9.3

Characterist
ics of
Various
Scheduling
Policies

(Table can be
found on page
405 in textbook)
Selection Function
 Determines which process, among ready processes, is selected
next for execution
 May be based on priority, resource requirements, or the execution
characteristics of the process
 If based on execution characteristics, then important quantities
are:
 w = time spent in system so far, waiting
 e = time spent in execution so far
 s = total service time required by the process, including e;
generally, this quantity must be estimated or supplied by the
user
Decision Mode
 Specifies the  Two categories:
instants in time  Nonpreemptiv
e
at which the
 Preemptive
selection
function is
exercised
Nonpreemptive vs
Preemptive
Nonpreemptiv Preemptive
e
 currently running
process may be
 once a process is in
interrupted and
the running state, it
moved to ready state
will continue until it
by the OS
terminates or blocks
itself for I/O  preemption may occur
when new process
arrives, on an
interrupt, or
periodically
Table 9.4
Process Scheduling Example
First-Come-First-
Served (FCFS)
 Simplest scheduling policy  Performs much better for
long processes than short
 Also known as first-in-first- ones
out (FIFO) or a strict
queuing scheme  Tends to favor processor-
bound processes over I/O-
 When the current process bound processes
ceases to execute, the
longest process in the
Ready queue is selected
Round Robin
 Uses preemption based on a  Particularly effective in a
clock general-purpose time-
sharing system or
 Also known as time slicing transaction processing
because each process is system
given a slice of time before
being preempted  One drawback is its relative
treatment of processor-
 Principal design issue is the bound and I/O-bound
length of the time quantum, processes
or slice, to be used
Shortest Process Next
(SPN)
 Nonpreemptive policy in  One difficulty is the need to
which the process with the know, or at least estimate,
shortest expected processing the required processing
time is selected next time of each process
 A short process will jump to  If the programmer’s
the head of the queue estimate is substantially
under the actual running
 Possibility of starvation for
time, the system may abort
longer processes
the job
Shortest Remaining
Time (SRT)
 Preemptive version of SPN
 Should give
 Scheduler always chooses superior
the process that has the turnaround
shortest expected time
remaining processing time performance to
SPN because a
 Risk of starvation of longer
short job is
processes
given
immediate
preference to a
running longer
job
Highest Response
Ratio Next (HRRN)
 Chooses next  While shorter jobs
process with the are favored, aging
greatest ratio without service
increases the ratio
 Attractive because it so that a longer
accounts for the age process will
of the process eventually get past
competing shorter
jobs
Fair-Share Scheduling
 Scheduling decisions based on the process
sets
 Each user is assigned a share of the
processor
 Objective is to monitor usage to give fewer
resources to users who have had more
than their fair share and more to those who
have had less than their fair share
Summary
 Typesof  Scheduling
processor algorithms
 Short-term
scheduling
scheduling criteria
 Long-term  The use of
scheduling priorities
 Medium-term  Alternative
scheduling policies
scheduling
 Fair-share
 Short-term
scheduling
scheduling
EXERCISES
Draw the Gantt Charts and compute the ‘average
waiting time’ and ‘average turnaround time’ using each
of the following scheduling algorithms:
Process Arrival Burst time
Time (ms)
P1 0 14
P2 2 12
P3 4 8
a. FCFS P4
b. SJN/SPN 5 4
c. SRT P5 17 7
d. HRRN
e. Round Robin using a time quantum of 6.
EXERCISES
 Draw the Gantt Charts and compute the
‘average waiting time’ and ‘average
turnaround time’ using each of the
following scheduling algorithms:
Process Arrival Burst time
a. FCFS Time (ms)
P1 0 10
b. SJN/SPN P2 5 7
P3 7 2
c. SRT
P4 10 10
d. HRRN P5 14 5
e. Round Robin using a time quantum of
4.

You might also like