1 / 26

2.5 Scheduling

2.5 Scheduling. Given a multiprogramming system. Many times when more than 1 process is waiting for the CPU (in the ready queue). The scheduler (using a scheduling algorithm ) decides which process will run next. User satisfaction is important. Context switch.

winfield
Download Presentation

2.5 Scheduling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2.5 Scheduling • Given a multiprogramming system. • Many times when more than 1 process is waiting for the CPU (in the ready queue). • The scheduler (using a scheduling algorithm) decides which process will run next. • User satisfaction is important.

  2. Context switch • When the CPU changes from one process to another. • Expensive operation. • User mode to kernel mode • Save state of current process • Registers, invalidate cache, MMU • Run scheduler • Pick next process to run • Load state of next process • Run next process

  3. Process behavior • Types: • I/O bound – spend most time performing I/O • Compute bound – spend most time performing computation • Mixture

  4. When do we need to schedule? • creation (before/after parent?) • exit • block (I/O, semaphore, sleep, wait, etc.) • I/O interrupt/completion • clock interrupt • non preemptive (run until you block or “cooperate” • preemptive

  5. Scheduling environments • Batch • Interactive • Real time

  6. Scheduling algorithm goals

  7. Concepts & definitions • Throughput = # of jobs completed per hour • Turnaround time = avg of “start (submit) to completion” times; avg wait time • CPU utilization = avg of CPU busyness • Response time = time between issuing a command and getting the result • Proportionality = user perception that “complex” things take a long time and that is fine but “simple” things must be quick • Predictability = regularity, especially important for audio and video streaming

  8. Batch scheduling • First-come first-served • Shortest job first • Shortest remaining time next • Three-level scheduling

  9. Batch scheduling • First-come first-served • Simple • Non preemptive • Process runs until it either blocks on I/O or finishes

  10. Batch scheduling • Shortest job first • Optimal turnaround time (when all start together) • Requires that we know run time a priori

  11. Batch scheduling • Shortest remaining time next • Preemptive version of shortest job first • Requires a priori information • When a new job arrives, its total time is compared to the current process’ remaining time. If the new job needs less time to finish, the new job is started. • New, short jobs get good service

  12. Batch scheduling • Three-level scheduling • Admission scheduler – chooses next job begin • Memory scheduler – which jobs are kept in memory and which jobs are swapped to disk • How long swapped in or out? • How much CPU time recently? • How big is the process? • How important is the process? • Degree of multiprogramming – number of processes in memory • CPU scheduler – picks which runs next

  13. Interactive scheduling • Round-robin scheduling • Priority scheduling • Multiple queues • Shortest process next • Guaranteed scheduling • Lottery scheduling • Fair-share scheduling

  14. Interactive scheduling • Round-robin scheduling • Simple, fair, widely, used, preemptive • Quantum = time interval • Process/context switch is expensive • Too small and we waste time • Too large and interactive system will appear sluggish • ~20-50 msec is good • Every process has equal priority

  15. Interactive scheduling • Priority scheduling • Each process is assigned a priority; process with highest priority is next to run. • Types: static or dynamic (ex. I/O bound jobs get a boost) • Unix/Linux nice command

  16. Interactive scheduling • Ex. 4 priorities & RR w/in a priority

  17. Interactive scheduling • Multiple queues • Different types • Ex. 4 queues for: • Terminal, I/O, short quantum, and long quantum

  18. Interactive scheduling • Shortest process next • Shortest job first always produces min avg response time (for batch systems) • How do we estimate this? • From recent behavior • Example of aging (or IIR filter) • alpha near 1 implies little memory • alpha near 0 implies much memory

  19. Interactive scheduling • Guaranteed scheduling • Given n processes, each process should get 1/n of the CPU time • Say we keep track of the actual CPU used vs. what we should receive (entitled to/deserved). • K = actual / entitled • K = 1  we got what we deserved • K < 1  we got less than deserved • K > 1  we got more than deserved • Pick process w/ min K to run next

  20. Interactive scheduling • Lottery scheduling • Each process gets tickets; # of tickets can vary from process to process. • If you ticket is chosen, you run next. • Highly responsive (new process might run right away) • Processes can cooperate (give each other their tickets)

  21. Interactive scheduling • Fair-share scheduling • Consider who (user) owns the process • Ex. • User A has 1 process • User B has 9 processes • Should user A get 10% and user B get 90% or should A get 50% and B get 50% (5.6% for each of the 9 processes)? Latter is fair-share.

  22. Real time scheduling • Time plays and essential role • Must react w/in a fixed amount of time • Categories: • Hard • Soft • Event types: • Periodic = occurring at regular intervals • Aperiodic = occurring unpredictably • Algorithm types: • Static • Dynamic

  23. Real time scheduling • Given m periodic events. • Event i occurs w/ period Pi and requires Ci seconds of CPU time • Schedulable iff:

  24. Schedulable example • Given Pi = 100, 200, and 500 msec • Given Ci = 50, 30, 100 msec • Can we handle another event w/ P4=1 sec? • Yes, as long as C4<=150 msec

  25. Thread scheduling • User level threads • No clock interrupts (per thread) • A compute bound thread will dominate its process but not the CPU • A thread can yield to other threads within the same process • Typically round robin or priority + Context switch from thread to thread is simpler + App specific thread scheduler can be used - If a thread blocks on I/O, the entire process (all threads) block

  26. Thread scheduling • Kernel level threads - Context switch from thread to thread is expensive (but scheduler can make more informed choices) + A thread, blocking on I/O, doesn’t block all other threads in process

More Related