0% found this document useful (0 votes)
119 views32 pages

Chapter 9 Uniprocessor Scheduling

The document discusses different types of scheduling decisions made by an operating system including long-term, medium-term, and short-term scheduling. It describes various scheduling algorithms like first-come first-served, round robin, shortest job next, and their properties. It also compares different scheduling policies and discusses concepts like preemptive and non-preemptive scheduling.

Uploaded by

lyumengyikr
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)
119 views32 pages

Chapter 9 Uniprocessor Scheduling

The document discusses different types of scheduling decisions made by an operating system including long-term, medium-term, and short-term scheduling. It describes various scheduling algorithms like first-come first-served, round robin, shortest job next, and their properties. It also compares different scheduling policies and discusses concepts like preemptive and non-preemptive scheduling.

Uploaded by

lyumengyikr
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/ 32

Operating

Systems:
Internals
and Chapter 9
Design Uniprocessor
Principles
Scheduling
Seventh Edition
By William Stallings

Dave Bremer
Otago Polytechnic, N.Z.
Operating Systems:
Internals and Design Principles

“I take a two hour nap, from


one o’clock to four.”

— Yogi Berra
Processor Scheduling
 Aim is to assign processes to be executed by the processor
in a way that meets system (performance) objectives, such
as response time, throughput, and processor efficiency
 Broken down into three separate functions:

medium
long term short term
term
scheduling scheduling
scheduling
Table 9.1
Types of Scheduling
Scheduling and Process State Transitions
Figure 9.2
Nesting of
Scheduling Functions

(Referencing Figure 3.9b)


Que
uing
Dia
gra
m
Long-Term Scheduler
 Determines which programs
are admitted to the system Creates processes
from the queue when
for processing it can, but must
decide:
 Controls the degree of
multiprogramming
 the more processes that when the operating
which jobs to accept
are created, the smaller system can take on
and turn into
the percentage of time one or more
processes
additional processes
that each process can
be executed
 may limit to provide
satisfactory service to first come, first
priority, expected
the current set of execution time, I/O
served
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 of another
Examples:
• 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 certain User-oriented criteria System-oriented
aspects of • relate to the behavior of criteria
system behavior the system as perceived by • focus in on effective and
the individual user or efficient utilization of the
process (such as response processor (rate at which
 A set of criteria time in an interactive processes are completed)
is needed to system) • generally of minor
• important on virtually all
evaluate the importance on single-user
systems systems
scheduling
policy
Short-Term Scheduling Criteria:
Performance
examples: example:
• response time Criteria can • predictability
• throughput be classified
into:

Performance-related Non-performance related

easily hard to
quantitative qualitative
measured measure
Table 9.2
Scheduling
Criteria
Priority
Queuing
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
Alternative Scheduling Policies
Decision Mode
 Specifies the  Two categories:
instants in time at  Nonpreemptive
which the selection  Preemptive
function is
exercised
Nonpreemptive vs Preemptive

Nonpreemptive Preemptive
 once a process is in the running  currently running process may
state, it will continue until it be interrupted and moved to
terminates, blocks itself for ready state by the OS
I/O, or give up voluntarily  preemption may occur when
new process arrives, on an
interrupt, or periodically
Table 9.4
Process Scheduling
Example
Table 9.5

Comparison of
Scheduling
Policies

• RR: Round Robin


• SPN: Shortest Process Next
• SRT: Shortest Remaining
Time
• HRRN: Highest Response
Ratio Next
• FB: Feedback
First-Come-First-Served
(FCFS)
 Simplest scheduling policy
 Performs much better for long
 Also known as first-in-first-out processes than short ones
(FIFO) or a strict queuing scheme
 Tends to favor processor-bound
 When the current process ceases processes over I/O-bound
to execute, the longest process in processes
the Ready queue is selected
Round Robin
 Uses preemption based on a clock  Particularly effective in a general-
purpose time-sharing system or
 Also known as time slicing because transaction processing system
each process is given a slice of time
before being preempted  One drawback is its relative
treatment of processor-bound and
 Principal design issue is the length I/O-bound processes
of the time quantum, or slice, to be
used
Figure 9.6a
Effect of Size
of
Preemption
Time
Quantum
Figure 9.6b
Effect of Size of Preemption Time Quantum
Virtual Round
Robin (VRR)

“Favor” I/O-bound
processes to provide
fairness and higher
I/O device utilization
Shortest Process Next
(SPN)
 Nonpreemptive policy in which the  One difficulty is the need to know,
process with the shortest expected or at least estimate, the required
processing time is selected next processing time of each process
 A short process will jump to the  If the programmer’s estimate is
head of the queue substantially under the actual
running time, the system may
 Possibility of starvation for longer
abort the job
processes
Shortest Remaining Time
(SRT)
 Preemptive version of SPN  Should give superior turnaround
time performance to SPN because
 Scheduler always chooses the a short job is given immediate
process that has the shortest preference to a running longer
expected remaining processing job
time

 Risk of starvation of longer


processes
Highest Response Ratio Next
(HRRN)
 Chooses next process with the  While shorter jobs are favored,
greatest ratio aging without service increases
the ratio so that a longer process
 Attractive because it accounts for will eventually get past competing
the age of the process shorter jobs
Feedback
Scheduling
• Preemptive with
time quantum
• Demoted to the
next lower-
priority queue
• With each
queue (except
the lowest
priority queue),
FCFS
• Lowest-priority
queue: RR
Feedback
Performance
Performance Comparison
 Any scheduling discipline that chooses the next item to be served
independent of service time obeys the relationship:
Summary
 The operating system must make three types of scheduling decisions with respect to
the execution of processes:
 Long-term – determines when new processes are admitted to the system
 Medium-term – part of the swapping function and determines when a program
is brought into main memory so that it may be executed
 Short-term – determines which ready process will be executed next by the
processor

 From a user’s point of view, response time is generally the most important
characteristic of a system; from a system point of view, throughput or processor
utilization is important

 Algorithms:

 FCFS, Round Robin, SPN, SRT, HRRN, Feedback

You might also like