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

Ch09 OS9e

The document summarizes scheduling in operating systems. It discusses long, medium, and short term scheduling. Long term scheduling determines which programs are admitted to the system. Medium term scheduling manages degree of multiprogramming through swapping. Short term scheduling, known as dispatching, decides the next process to execute in response to events. It aims to optimize criteria like response time and throughput. Scheduling policies are nonpreemptive or preemptive depending on if currently running processes can be interrupted.
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)
67 views46 pages

Ch09 OS9e

The document summarizes scheduling in operating systems. It discusses long, medium, and short term scheduling. Long term scheduling determines which programs are admitted to the system. Medium term scheduling manages degree of multiprogramming through swapping. Short term scheduling, known as dispatching, decides the next process to execute in response to events. It aims to optimize criteria like response time and throughput. Scheduling policies are nonpreemptive or preemptive depending on if currently running processes can be interrupted.
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/ 46

Operating

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

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Table 9.1

Types of Scheduling

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


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

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Long-Term Scheduler
 Determines which programs Creates processes
are admitted to the system for from the queue when
it can, but must
processing decide:
 Controls the degree of
multiprogramming
 The more processes that When the operating
are created, the smaller Which jobs to accept
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
the current set of Priority, expected
First come, first
execution time, I/O
processes served
requirements

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


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

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


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)

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


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 by • Focus is on effective and
the individual user or efficient utilization of the
 A set of criteria is process (such as response processor (rate at which
needed to evaluate time in an interactive processes are completed)
the scheduling system) • Generally of minor
• Important on virtually all importance on single-user
policy
systems systems

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Short-Term Scheduling Criteria:
Performance
Examples: Example:
• Response time Criteria can • Predictability
and throughput be classified
into:

Non-performance
Performance-related
related

Easily Hard to
Quantitative Qualitative
measured measure

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Table 9.2

Scheduling Criteria

(Table can be found on page 403 in textbook)

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Table 9.3

Characteristics of
Various
Scheduling
Policies

(Table can be found


on page 405 in
textbook)

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


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

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Decision Mode
 Specifies the  Two categories:
instants in time at  Nonpreemptive
which the selection  Preemptive
function is
exercised

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Nonpreemptive vs Preemptive

Nonpreemptive Preemptive
 Currently running process
may be interrupted and
 Once a process is in the moved to ready state by the
running state, it will OS
continue until it terminates  Decision to preempt may be
or blocks itself for I/O performed when a new
process arrives, when an
interrupt occurs that places
a blocked process in the
Ready state, or periodically,
based on a clock interrupt

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Table 9.4
Process Scheduling Example

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Table 9.5

A Comparison
of Scheduling
Policies

(Table is on page 408 in textbook)

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


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
 As each process becomes ready, it processes over I/O-bound
joins the ready queue processes

 When the currently running


process ceases to execute, the
process that has been in the ready
queue the longest is selected for
running

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


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

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
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

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Shortest Remaining Time
(SRT)
 Preemptive version of SPN
 Should give
 Scheduler always chooses the superior turnaround
process that has the shortest time performance
expected remaining processing to SPN because a
time short job is given
immediate
 Risk of starvation of longer
preference to a
processes
running longer job

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Highest Response Ratio Next
(HRRN)
 Chooses next process  While shorter jobs are
with the greatest ratio favored, aging without
service increases the ratio
 Attractive because it so that a longer process
accounts for the age of will eventually get past
the process competing shorter jobs

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Performance Comparison
 Any scheduling discipline that chooses the next item to be served
independent of service time obeys the relationship:

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Table 9.6

Formulas
for Single-
Server
Queues
with Two
Priority
Categories

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights
reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
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

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Fair Share Scheduler (FFS)
The following formulas apply for process j in group k :
CPUj(i – 1)
CPUj(i) = 2

GCPUk(i - 1)
GCPUk(i) = 2

CPUj(i) GCPUk(i)
Pj(i) = Basej + 2 + 4 x Wk

where

CPUj(i) = measure of processor utilization by process j through interval i,


GCPUk(i) = measure of processor utilization of group k through interval i,
Pj(i) = priority of process j at beginning of interval i; lower values equal
higher priorities,
Basej = base priority of process j, and
Wk = weighting assigned to group k, with the constraint that and
© 2017 Pearson Education, Inc., Hoboken,
0 < Wk NJ.
< 1Alland
rights
∑ Wreserved.
k = 1.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Traditional UNIX Scheduling
 Used in both SVR3 and 4.3 BSD UNIX
 These systems are 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
 Employs multilevel feedback using round robin within each of the priority
queues
 Makes use of one-second preemption
 Priority is based on process type and execution history

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


Scheduling Formula

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


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

© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.


© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Summary
 Types of processor  Scheduling
scheduling
algorithms
 Long-term scheduling
 Short-term scheduling
 Medium-term
criteria
scheduling
 The use of priorities
 Short-term scheduling
 Alternative scheduling
 Traditional UNIX policies
scheduling  Performance
comparison
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.  Fair-share scheduling

You might also like