Chapter09

Report
Operating Systems:
Internals and Design Principles, 6/E
William Stallings
Chapter 9
Uniprocessor Scheduling
Patricia Roy
Manatee Community College, Venice, FL
©2008, Prentice Hall
Aim of Scheduling
• Assign processes to be executed by the
processor(s)
• Response time
• Throughput
• Processor efficiency
Processor Scheduling
• Known as the dispatcher
• Invoked when an event occurs
– Clock interrupts
– I/O interrupts
– Operating system calls
– Signals
Processor Scheduling Criteria
• User-oriented
– Response Time
• Elapsed time between the submission of a request
until there is an output
– Turnaround Time
• The time between the submission and the
completion of a process
• System-oriented
– Effective and efficient utilization of the
processor
Decision Mode
• Nonpreemptive
– Once a process is in the running state, it will
continue until it terminates or blocks itself for I/O
Decision Mode
• Preemptive
– Currently running process may be interrupted
and moved to the Ready state by the
operating system
– Allows for better service since any one
process cannot monopolize the processor for
very long
Priorities
• Scheduler will always choose a process of
higher priority over one of lower priority
• Have multiple ready queues to represent
each level of priority
Priority Queuing
Priorities
• Lower-priority may suffer starvation
– Allow a process to change its priority based
on its age or execution history
First-Come-First-Served
• Each process joins the Ready queue
• When the current process ceases to
execute, the process that waits the longest
in the Ready queue is selected
Process Scheduling Example
First-Come-First-Served
• A short process may have to wait a very
long time before it can execute
• Favors CPU-bound processes
– I/O processes have to wait until CPU-bound
process completes
– Low utilization for I/O devices
– Possibly low utilization for processor
Round Robin
• Clock interrupt is generated at periodic
intervals
• When an interrupt occurs, the currently
running process is placed in the ready
queue
– Next ready job is selected
• Known as time slicing
Round Robin
• Uses preemption based on a clock
Round Robin
• Time quantum is
– The time interval between two clock interrupts
– The maximum time allocated to a process’s
execution in each turn
Round Robin
• Which type of processes are favored by
round robin scheduling?
– CPU or I/O bound processes?
Round Robin
Example:
A
B
C
D
E
A, C, D, E: CPU bound processes;
B: I/O bound process.
What should we do to treat
them fairly in terms of CPU
allocation?
Round Robin
• Which type of processes are favored by
round robin scheduling?
– CPU or I/O bound processes?
• Favors CPU-bound processes
– CPU-bound process gets more CPU time
– I/O process has to wait for CPU-bound
processes to consume their quanta before its
turn of executing on the CPU
Queuing Diagram
Virtual round robin
Use an auxiliary queue to
hold processes that have I/O
requests serviced
Process in auxiliary queue
gets preference over those in
the main ready queue
Process from the auxiliary
queue runs for remaining time
from last time-slice
Shortest Process Next
• Process with shortest expected processing
time is selected next
• Short process jumps ahead of longer
processes
• Nonpreemptive policy
Shortest Process Next
Shortest Process Next
• Possibility of starvation for longer processes
• If estimated time for process not correct, the
operating system may abort it
• How to estimate a process execution time?
• Average of history?
• Simple average: Sn+1 = 1/n  Ti
• Exponential average: Sn+1 = Tn + (1-)Sn
– Greater weights to more recent instances
Shortest Remaining Time
• Preemptive version of shortest process next
policy
Highest Response Ratio Next
• Choose next process with the greatest ratio
– shorter processes are favored
– aging without service increases the ratio so that
a longer process will eventually be served
Highest Response Ratio Next
• Choose next process with the greatest ratio
Feedback Scheduling
• Don’t know remaining time process needs
to execute
• Penalize jobs that have been running
longer: putting them into lower priority
ready queues
Feedback Scheduling
Feedback Scheduling
Fair-Share Scheduling
• User’s application runs as a collection of
processes (threads)
• User is concerned about the performance
of the application
• Need to make scheduling decisions based
on process sets
Fair-Share Scheduling
• CPUj(i) = CPUj(i-1)/2
• GCPUk(i) = GCPUk(i-1)/2
• Pj(i) = Basej + CPUj(i)/2 + GCPUk(i)/(4Wk)
Fair-Share Scheduler
In-Class Exercise
• Prob. 9.2 Consider the following set of
processes:
Process Name
Arrival Time
Processing Time
A
B
C
D
E
0
1
3
9
12
3
5
2
5
5
Perform FCFS, RR (q=4), SPN, SRT, HRRN,
Feedback (q=2i) on them and get the Finish
Time and Turnaround Time for each process.
Appendix
Exponential Smoothing
Coefficients
Use Of Exponential Averaging
Use Of Exponential Averaging
Effect of Size of Preemption
Time Quantum
Effect of Size of Preemption
Time Quantum

similar documents