1 Lecture 5: Uniprocessor Scheduling Advanced Operating System Fall 2010.
Uniprocessor Scheduling
description
Transcript of Uniprocessor Scheduling
Uniprocessor Scheduling
Chapter 9(Continued)
Acknowledgment
• Several (most?) transparencies are from the slide set prepared by Patricia Roy,
and available on the Stallings OS site (many transparencies have been modified, and some added, to suit my plans)
Decision Mode• Nonpreemptive
– Once a process is in the running state, it will continue until it terminates or blocks itself for I/O
• 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
Process Scheduling Example
FCFS Assuming processes do not perform any I/O
• Each process joins the Ready queue• When the current process ceases to execute,
the oldest process in the Ready queue is selected
0 5 10 15 20
1
2345
First-Come-First-Served(FCFS)
• If processes do not perform I/O, a short process may have to wait a very long time before it can execute
• If processes perform I/O, and both I/O-bound and CPU-bounds processes exist,
FCFS policy favors CPU-bound processes.
**** Someone explain this!!!
Round-Robin
• Uses preemption based on a clock• Again, someone explain this!!!
0 5 10 15 20
1
2345
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 process is selected
• Known as time slicing
Shortest Process Next
• Nonpreemptive policy• Process with shortest expected processing time
is selected next• Short process jumps ahead of longer processes
0 5 10 15 20
1
2345
Shortest Process Next• Predictability of longer processes is
reduced• If estimated time for process not correct,
the operating system may abort it• Possibility of starvation for longer
processes• Very difficult to use in practice!• Q: Does it offer better throughput than,
say, FCFS or round-robin?
Shortest Remaining Time
• Preemptive version of shortest process next policy
• Must estimate processing time correctly
0 5 10 15 20
1
2345
Highest Response Ratio Next (HRRN)
• Choose next process with the highest ratio
time spent waiting + expected service timeexpected service time
1
2345
0 5 10 15 20
Feedback
• Penalize processes that use too much CPU time by reducing priority of a process every time it gets preempted
• High priority given when it finishes I/O
0 5 10 15 20
1
2345
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 in an application• A `fair share’ for an application (or
group of processes) is a specified fraction of CPU time
Fair-share scheduling
• Specify fair shares for different applications/groups of processes
• Try to provide the fair share to each group
• Accumulate the CPU time used -- individually by each process -- by groups of processes and adjust process priorities accordingly
Fair-share scheduling
• CPU(i) = CPU(i-1)/2 -- for a process• GCPU(i) = GCPU(i-1)/2 – for a group
• P(i) = Base + CPU(i-1)/2 + GCPU(i-1)/(4 x W) where `w’ is the fair share of the group of processes
UNIX Scheduling
• Multilevel feedback using round robin within each of the priority queues
• Priorities are recomputed once per second
• A large numerical value of priority indicates low effective priority
UNIX Scheduling
Compute P(i) every second as follows: CPU(i) = CPU(i-1)/2• P(i) = Base + CPU(i-1)/2 + nice• *** Change CPU(i-1) to CPU(i) ***??!!• Base priority divides all processes into
fixed bands of priority levels• Adjustment factor used to keep process
in its assigned band
Priority Bands
• Base priorities are defined to provide decreasing order of priority to– Swapper– Block I/O device control– File manipulation– Character I/O device control– User processes
Unix scheduling
• How is this scheduling different from round robin scheduling with time slicing?