0% found this document useful (0 votes)
437 views46 pages

Operating Systems: Internals and Design Principles: Uniprocessor Scheduling

This document summarizes different approaches to uniprocessor scheduling in an operating system. It discusses long-term, medium-term, and short-term scheduling and different criteria used for short-term scheduling like response time, throughput, and predictability. It also describes common scheduling policies like first-come, first-served, priority scheduling, round robin, and their tradeoffs in terms of turnaround time, response time, and ability to handle different process types.

Uploaded by

Onur Yılmazer
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)
437 views46 pages

Operating Systems: Internals and Design Principles: Uniprocessor Scheduling

This document summarizes different approaches to uniprocessor scheduling in an operating system. It discusses long-term, medium-term, and short-term scheduling and different criteria used for short-term scheduling like response time, throughput, and predictability. It also describes common scheduling policies like first-come, first-served, priority scheduling, round robin, and their tradeoffs in terms of turnaround time, response time, and ability to handle different process types.

Uploaded by

Onur Yılmazer
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/ 46

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 objectives, such as
response time, throughput, and processor efficiency
◼ Broken down into three separate functions:

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

(Referencing figure 3.9b)


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

Non-performance
Performance-related
related

easily hard to
quantitative qualitative
measured measure
Table 9.2
Scheduling
Criteria
Priority
Queuing
◼ Determines which Ready process is dispatched next
◼ May be based on priority, resource requirements, or the
execution characteristics of the process
◼ If based on execution characteristics, some factors to
consider 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;
(estimated by system or user)
▪ When/under what ▪ Two categories:
circumstances is the ▪ Nonpreemptive
selection function is ▪ Preemptive
exercised?
Nonpreemptive Preemptive
◼ currently running
◼ once a process is in process may be
the running state, it interrupted and moved
will continue until it to ready state by the OS
terminates or blocks ◼ preemption may occur
itself for I/O when a new process
arrives, on an interrupt,
or periodically
Alternative Scheduling Policies
Table 9.4
Process Scheduling
Example
Table 9.5

Comparison
of
Scheduling
Policies
(Assumes no process
blocks itself, for I/O or
other event wait.)
◼ Simplest scheduling policy
◼ Performs much better for long
◼ Also known as first-in-first-out processes than short ones
(FIFO) or a strict queuing
◼ Tends to favor processor-bound
scheme
processes over I/O-bound
◼ When the current process ceases processes
to execute, the longest process in
the Ready queue is selected
◼ Uses preemption based on a clock ◼ Particularly effective in a
general-purpose time-sharing
◼ Also known as time slicing system or transaction processing
because each process is given a system
slice of time before being
preempted ◼ One drawback is its relative
treatment of processor-bound
◼ Principal design issue is the length and 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)
◼ Nonpreemptive policy in which ◼ One difficulty is the need to
the process with the shortest know, or at least estimate, the
expected processing time is required processing time of each
selected next 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
◼ Problem: Estimating ◼ Problem: avoiding
execution time starvation for long
processes
◼ OS may collect statistics
and use process history ◼ Problem: not suitable
to estimate run time for timesharing or
◼ e.g., for processes in a transaction processing
production due to no preemption.
environment
◼ Preemptive version of SPN ◼ Should give superior turnaround
time performance to SPN
◼ Scheduler always chooses the because a short job is given
process that has the shortest immediate preference to a
expected remaining processing running longer job
time
◼ Still depends on having accurate
◼ Risk of starvation of longer service time estimates.
processes
◼ 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 will eventually get past
for the age of the process competing shorter jobs
◼ Scheduling is similar to RR:
Multilevel Feedback FCFS with a time quantum.

◼ However, when a process blocks


Scheduling or is preempted it is “fed back”
into the next lower level queue.

◼ Once it reaches the lowest level


Useful when queue a process is served by RR
until it terminates.
• there is no information about
relative length of various jobs, ◼ Process is dispatched from the
but highest priority non-empty
• You would like to favor short queue
jobs
◼ Result: new processes favored
• Basic algorithm may starve long over long older processes
processes or I/O bound
processes. ◼ Modifications address starvation
and I/O bound processes
Feedback
Scheduling
Feedback
Performance
Feedback Queue
Modifications
◼ To avoid unreasonably long waits for long processes, give
processes in lower-priority queues longer quantums

◼ To avoid starvation let a process that has not executed for a


certain amount of time move to a higher level queue.

◼ To lessen the penalty on I/O bound processes use some


version of virtual RR for processes that don’t receive a full
quantum.
Performance Comparison
◼ Any scheduling discipline that chooses the next item to be served
independent of service time obeys the relationship:
Table 9.6

Formulas
for Single-
Server
Queues
with Two
Priority
Categories
Overall Normalized Response Time
Normalized Response Time for
Shorter Processes
Normalized Response
Time for Longer Processes
Results

Simulation
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
Fair-Share
Scheduler
Traditional UNIX Scheduling
◼ Used in both SVR3 and 4.3 BSD UNIX
◼ these systems were primarily targeted at the time-sharing interactive
environment

◼ Designed to provide good response time for interactive users while


ensuring that low-priority background jobs do not starve

◼ Employed multilevel feedback using round robin within each of the


priority queues

◼ Made use of one-second preemption

◼ Priority based on process type and execution history


Scheduling Formula
Bands
Swapper
◼ Used to optimize access
to block devices and to
allow the operating Block I/O
system to respond device control
quickly to system calls
File
◼ In decreasing order of manipulation
priority, the bands are:
Character I/O
device control

User
processes
Example of
Traditional
UNIX Process
Scheduling
◼ 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