340 likes | 429 Vues
Learn about long-term, medium-term, and short-term scheduling in uniprocessor systems, including criteria, priorities, and decision modes. Discover various scheduling algorithms such as FCFS, Round-Robin, SPN, SRT, HRRN, and Feedback.
E N D
Uniprocessor Scheduling Chapter 9
Aim of Scheduling • The key to multiprogramming is scheduling • Scheduling is done to meet the goals of • Response time • Throughput • Processor efficiency
Three Types • Long term scheduling: Degree of multiprogramming in the system • Medium term scheduling: Disk to memory migration • Short term scheduling: Ready to running migration
Long-Term Scheduling • Determines which programs are admitted to the system for processing • Controls the degree of multiprogramming • More processes, smaller percentage of time each process is executed
Medium-Term Scheduling • Part of the swapping function • Disk to main memory (swap-in or swap-out) • Based on the need to manage the degree of multiprogramming
Short-Term Scheduling • Known as the dispatcher • Executes most frequently • Invoked when an event occurs • Clock interrupts • I/O interrupts • Operating system calls • Signals
Short-Tem Scheduling Criteria • User-oriented • Response Time • Elapsed time between the submission of a request until there is output. • System-oriented • Effective and efficient utilization of the processor i.e. throughput • Not important on single-user system
Short-Term Scheduling Criteria • Performance-related • Quantitative • Measurable such as response time and throughput • Not performance related • Qualitative • Predictability (The system appears same to the users over a period of time)
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 • Lower-priority may suffer starvation • allow a process to change its priority based on its age or execution history
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 • More overhead but allows for better service since any one process cannot monopolize the processor for very long
5 0 10 15 20 First-Come-First-Served(FCFS) • Each process joins the Ready queue • When the current process ceases to execute, the oldest process in the Ready queue is selected A B C D E
First-Come-First-Served(FCFS) • A short process may have to wait a very long time before it can execute • Favors processor bound processes • I/O processes have to wait until processor bound process completes • Then the I/O bound process quickly runs its processor cycle and blocks again for I/O
5 0 10 15 20 Round-Robin • Uses preemption based on a clock • An amount of time is determined that allows each process to use the processor for that length of time A B C D E
Round-Robin • Clock interrupt is generated at periodic intervals • When an interrupt occurs, the currently running process is placed in the ready queue and the next ready job is selected • Known as time slicing; If slice is short, large overhead in switching tasks • If each process runs to completion, RR changes into FCFS • To avoid unfair treatment of I/O bound processes, VRR prefers older processes over newer ones
5 0 10 15 20 1 2 3 4 5 Shortest Process Next • Nonpreemptive policy to prefer short processes • Process with shortest expected processing time is selected next • Short process jumps ahead of longer processes A B C D E
Shortest Process Next • How to estimate the process length? • EWMA is used to estimate duration. It gives more weight to recent burst times • 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
5 0 10 15 20 1 2 3 4 5 Shortest Remaining Time • Preemptive version of SPN policy • Must estimate processing time • Similar features as SPN but better turnaround because a short new process is preferred A B C D E
5 0 10 15 20 Highest Response Ratio Next (HRRN) • Choose next process with the lowest ratio R where R is A B C D E 1 2 3 4 5 time spent waiting + expected service time expected service time
HRRN • When a process is new, waiting time is zero • Thus the minimum value of R is 1.0 • If the process is short, R is ________? • If the process is waiting for long time, R becomes________? • Always choose the process with largest R • No starvation
5 0 10 15 20 1 2 3 4 5 Feedback • Penalize jobs that have been running longer • Don’t know remaining time process needs to execute but we know how long the process has executed • Every time a process is preempted, it is placed in a lower priority queue A B C D E
Feedback Scheduling • All queues run as FCFS except for the lowest priority queue • The lowest priority queue runs as RR • The feedback scheduling may punish long processes heavily so a variation is suggested that increases the time slice as a process goes down the lower priority queues
Fair-Share Scheduling • User’s application runs as a collection of processes (threads) • User is concerned about the performance of the application • If Computer Science students are running a lot of jobs on the server, Math students should not see performance degradation for their jobs • We need to make scheduling decisions based on process sets • Each user or group is allocated a weight and this weight translates to fair share
Traditional UNIX Scheduling (Timeshared Interactive Model) • Multilevel feedback using round robin within each of the priority queues • Priorities are recomputed once per second (time slice = 1 second) • Base priority divides all processes into fixed bands of priority levels • Adjustment factor used to keep process in its assigned band
Bands • Decreasing order of priority • Swapper • Block I/O device control • File manipulation • Character I/O device control • User processes (favoring I/O bound)