230 likes | 352 Views
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).
E N D
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
5 0 10 15 20 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 1 2 3 4 5
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!!!
5 0 10 15 20 Round-Robin • Uses preemption based on a clock • Again, someone explain this!!! 1 2 3 4 5
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
5 0 10 15 20 1 2 3 4 5 Shortest Process Next • Nonpreemptive policy • Process with shortest expected processing time is selected next • Short process jumps ahead of longer processes
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?
5 0 10 15 20 1 2 3 4 5 Shortest Remaining Time • Preemptive version of shortest process next policy • Must estimate processing time correctly
5 0 10 15 20 Highest Response Ratio Next (HRRN) • Choose next process with the highest ratio 1 2 3 4 5 time spent waiting + expected service time expected service time
5 0 10 15 20 1 2 3 4 5 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
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?