uniprocessor scheduling
play

Uniprocessor Scheduling Basic Concepts Scheduling Criteria - PowerPoint PPT Presentation

Uniprocessor Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms 2 Three level scheduling 3 Types of Scheduling g yp Long- and Medium-Term Schedulers g Long-term scheduler Determines which programs are


  1. Uniprocessor Scheduling •Basic Concepts •Scheduling Criteria •Scheduling Algorithms

  2. 2 Three level scheduling

  3. 3 Types of Scheduling g yp

  4. Long- and Medium-Term Schedulers g Long-term scheduler • Determines which programs are admitted to the system (ie to become processes) • requests can be denied if e.g. thrashing or overload b d d f h h l d Medium-term scheduler • decides when/which processes to suspend/resume • Both control the degree of multiprogramming – More processes, smaller percentage of time each process is executed executed 4

  5. Short-Term Scheduler • Decides which process will be dispatched ; invoked upon – Interrupts, Operating system calls, Signals, .. • Dispatch latency – time it takes for the dispatcher to stop one process and start another running; the to stop one process and start another running; the dominating factors involve: – switching context g – selecting the new process to dispatch 5

  6. CPU–I/O Burst Cycle y • Process execution consists of a cycle of cycle of CPU execution and – – I/O wait. • A process may be – CPU-bound – IO-bound 6

  7. Scheduling Criteria- Optimization goals g p g CPU utilization – keep CPU as busy as possible Throughput – # of processes that complete their execution per time unit Response time – amount of time it takes from when a request was Response time amount of time it takes from when a request was submitted until the first response is produced (execution + waiting time in ready queue) – T Turnaround time – amount of time to execute a particular process d ti t f ti t t ti l (execution + all the waiting ); involves IO schedulers also Fairness - watch priorities, avoid starvation, ... Scheduler Efficiency - overhead (e.g. context switching, computing priorities, …) 7

  8. Decision Mode Nonpreemptive • O Once a process is in the running state, it will continue until it i i th i t t it ill ti til it terminates or blocks itself for I/O Preemptive • Currently running process may be interrupted and moved to the R Ready state by the operating system d t t b th ti t • Allows for better service since any one process cannot monopolize the processor for very long p y g 8

  9. First-Come-First-Served (FCFS) (FCFS) 5 5 0 0 10 10 15 15 20 20 A B C D E • non-preemptive • Favors CPU bound processes • Favors CPU-bound processes • A short process may have to wait very long before it can wait very long before it can execute ( convoy effect ) 9

  10. Round-Robin 5 5 0 10 15 20 A B C D E • preemption based on clock (interrupts on time ti b d l k (i t t ti slice or quantum -q- usually 10-100 msec) • fairness: for n processes, each gets 1/ n of the CPU time in chunks of at most q time units CPU time in chunks of at most q time units • Performance – q large ⇒ FIFO – q small ⇒ overhead can be high due to ll h d b hi h d t context switches 10

  11. Shortest Process First 5 0 0 10 10 15 15 20 20 A B C D E • Non-preemptive • Short process jumps ahead of l longer processes • Avoid convoy effect 11

  12. Shortest Remaining Time First g 5 5 0 0 10 10 15 15 20 20 A B C D E • Preemptive (at arrival) version of shortest process next next 12

  13. On SPF Scheduling • gives high throughput g s h gh throughput • gives minimum (optimal) average response (waiting) time for a given set of processes g p – Proof (non-preemptive): analyze the summation giving the waiting time • must estimate processing time (next cpu burst) – Can be done automatically (exponential averaging) – If estimated time for process (given by the user in a batch system) not correct the operating system may abort it system) not correct, the operating system may abort it • possibility of starvation for longer processes 13

  14. Determining Length of Next CPU Burst g g • Can be done by using the length of previous CPU bursts, using exponential averaging exponential averaging . = th 1. actual lenght of CPU burst t n n τ τ = 2 2. predicted predicted value value for for the the next next CPU CPU burst burst + n 1 1 α ≤ α ≤ 3. , 0 1 ( ) τ = α + − α τ t 1 . 4. Define : = n 1 n n 14

  15. On Exponential Averaging p g g • α =0 – τ n+1 = τ n – history does not count, only initial estimation counts • α =1 1 α – τ n+1 = t n – Only the actual last CPU burst counts. • If we expand the formula, we get: τ n+1 = α t n +( 1 - α ) α t n - 1 + … + ( 1 + ( 1 - α ) j α t n - i + … α ) j α t + + ( 1 - α ) n τ 0 • Since both α and (1 - α ) are less than or equal to 1, each successive term has less weight than its predecessor. 15

  16. Prediction of the Length of the Next CPU Burst

  17. Priority Scheduling: General Rules y g • Scheduler can choose a process of higher priority over one of lower priority f l i it – can be preemptive or non-preemptive – can have multiple ready queues to represent multiple level of – can have multiple ready queues to represent multiple level of priority • Example Priority Scheduling : SPF, where priority is p y g , p y the predicted next CPU burst time. • Problem ≡ Starvation – low priority processes may p y p y never execute. • A solution ≡ Aging – as time progresses increase the priority of the process. f h 17

  18. Priority Scheduling Cont. : Multilevel Queue y g Q • Ready queue is partitioned into separate queues eg queues, eg foreground (interactive) background (batch) • • Each queue has its own scheduling Each queue has its own scheduling algorithm, eg foreground – RR b background – FCFS k d FCFS • Scheduling must be done between the queues. – Fixed eg., serve all from foreground then from background. Possible starvation . – Another solution : Time slice – each queue gets a fraction of CPU time to divide t f ti f CPU ti t di id amongst its processes, eg. 80% to foreground in RR 20% t b 20% to background in FCFS k d i FCFS 18

  19. Multilevel Queue Scheduling Q g

  20. Multilevel Feedback Queue Q • A process can move b t between the various th i queues; aging can be implemented this way implemented this way. • scheduler parameters: • scheduler parameters: – number of queues – scheduling algorithm for each g g m f queue – method to upgrade a process – method to demote a process th d t d t – method to determine which queue a process will enter q p first 20

  21. 21 Multilevel Feedback Queues Q

  22. Thread Scheduling • Many-to-one and many-to-many models, thread M t d t d l th d library schedules user-level threads to run on LWP LWP – Known as process-contention scope (PCS) since scheduling competition is within the process • Kernel thread scheduled onto available CPU is system-contention scope (SCS) – competition among all threads in system • E.g. Pthreads scheduling API allows specifying either PCS or SCS during thread creation ith PCS SCS d i th d ti

  23. Fair-Share Scheduling • extention of multi-level queues with feedback + t nt on of mu t qu u s w th f ac priority recomputation – application runs as a collection of processes (threads) – concern: the performance of the application, user-groups, … (ie. group of processes/threads) – scheduling decisions based on process sets rather than scheduling decisions based on process sets rather than individual processes • eg. “traditional” unix sheduling g g 23

  24. Real-Time Scheduling

  25. Real-Time Systems y • Tasks or processes attempt to interact with outside-world events , which occur in “real time”; process must be able to keep up e g which occur in real time ; process must be able to keep up, e.g. – Control of laboratory experiments, Robotics, Air traffic control, Drive-by- wire systems, Tele/Data-communications, Military command and control systems y • Correctness of the RT system depends not only on the logical result of the computation but also on the time at which the results are produced i.e. Tasks or processes come with a deadline (for starting or completion) Requirements may be hard or soft 25

  26. Periodic Real-TimeTasks: Timing Diagram Timing Diagram 26

  27. E.g. Multimedia Process Scheduling A movie may consist of several files 27

  28. E.g. Multimedia Process Scheduling (cont) g g ( ) • Periodic processes displaying a movie • Frame rates and processing requirements may be different for each movie (or other process that requires time guarantees) i i ) 28

  29. Scheduling in Real-Time Systems Schedulable real-time system • Given – m periodic events m per od c events – event i occurs within period P i and requires C i seconds • Then the load can only be handled if Then the load can only be handled if m C ∑ ∑ P ≤ i 1 Utilization = P = i 1 i 29

  30. Scheduling with deadlines: Earliest Deadline First Earliest Deadline First Set of tasks with deadlines is schedulable (i.e can be executed in a way that no process misses its deadline) iff EDF is a schedulable (aka feasible) no process misses its deadline) iff EDF is a schedulable (aka feasible) sequence. Example sequences: 30

Recommend


More recommend