scheduling metrics fcfs rr sjf srtf
play

Scheduling: metrics / FCFS+RR / SJF+SRTF 1 last time fjnish pipe / - PowerPoint PPT Presentation

Scheduling: metrics / FCFS+RR / SJF+SRTF 1 last time fjnish pipe / read / write read: wait till something available, then copy whats available multithreaded process xv6: only single-threaded processes thread: registers, program counter,


  1. Scheduling: metrics / FCFS+RR / SJF+SRTF 1

  2. last time fjnish pipe / read / write read: wait till something available, then copy what’s available multithreaded process xv6: only single-threaded processes thread: registers, program counter, stack process: open fjles, memory contents (heap, etc.), process id, etc. xv6 scheduler organization separate scheduler thread switch to scheduler thread, scheduler thread fjnds next process scheduler thread iterates through available processes xv6 scheduler locking don’t look at thread state (running/waiting/etc.) while it might be changing don’t change thread state while something else might be looking at it 2

  3. goal/policy/mechanism end of last time — used terms policy and mechanism imprecisely goal : properties we want schedule to satisfy policy : how we choose to schedule to do it mechanism : how we switch processes, do bookkeeping, etc. 3

  4. the scheduling policy problem what RUNNABLE program should we run? xv6 answer: whatever’s next in list best answer? well, what should we care about? 4

  5. some simplifying assumptions welcome to 1970: one program per user one thread per program programs are independent 5

  6. recall: scheduling queues ready queue CPU I/O I/O queues I/O system call timer/etc. interrupt wait/… system call wait queues 6

  7. CPU and I/O bursts wait for I/O … web browser: wait for remote web server drawing program: wait for mouse presses/etc. shell: wait for keypresses examples: and waiting for I/O program alternates between computing … start write … compute on read data wait for I/O start read compute on read data wait for I/O (from fjle/keyboard/…) start read compute 7

  8. CPU bursts and interactivity (one c. 1966 shared system) shows compute time from command entered until next command prompt from G. E. Bryan, “JOSS: 20,000 hours at a console—a statistical approach” in Proc. AFIPS 1967 FJCC 8

  9. CPU bursts and interactivity (one c. 1990 desktop) shows CPU time from RUNNING until not RUNNABLE anymore from Curran and Stumm, “A Comparison of basic CPU Scheduling Algoirithms for Multiprocessor Unix” 9

  10. CPU bursts observation: applications alternate between I/O and CPU especially interactive applications but also, e.g., reading and writing from disk typically short “CPU bursts” (milliseconds) followed by short “IO bursts” (milliseconds) 10

  11. scheduling CPU bursts our typical view: ready queue, bunch of CPU bursts to run to start: just look at running what’s currently in ready queue best same problem as ‘run bunch of programs to completion’? later: account for I/O after CPU burst 11

  12. an historical note historically applications were less likely to keep all data in memory historically computers shared between more users meant more applications alternating I/O and CPU context many scheduling policies were developed in 12

  13. scheduling metrics response time (Anderson-Dahlin) AKA turnaround time (Arpaci-Dusseau) (want low ) (what Arpaci-Dusseau calls response time is slightly difgerent — more later) what user sees: from keypress to character on screen (submission until job fjnsihed) throughput (want high ) total work per second problem: overhead (e.g. from context switching) fairness many defjnitions all confmict with best average throughput/turnaround time 13

  14. turnaround and wait time wait for input ready running turnaround time (Anderson-Dahlin “response time”) + wait time (= turnaround time - running time) Arpaci-Dusseau’s “response time” common measure: mean turnaround time or total turnaround time same as optimizing mean/total waiting time 14

  15. turnaround and wait time wait for input ready running turnaround time (Anderson-Dahlin “response time”) + wait time (= turnaround time - running time) Arpaci-Dusseau’s “response time” common measure: mean turnaround time or total turnaround time same as optimizing mean/total waiting time 14

  16. turnaround and wait time wait for input ready running turnaround time (Anderson-Dahlin “response time”) + wait time (= turnaround time - running time) Arpaci-Dusseau’s “response time” common measure: mean turnaround time or total turnaround time same as optimizing mean/total waiting time 14

  17. turnaround and wait time wait for input ready running turnaround time (Anderson-Dahlin “response time”) + wait time (= turnaround time - running time) Arpaci-Dusseau’s “response time” common measure: mean turnaround time or total turnaround time same as optimizing mean/total waiting time 14

  18. turnaround time and I/O scheduling CPU bursts? (what we’ll mostly deal with) important for fully utilizing I/O devices scheduling batch program on cluster? once program done with CPU, it’s probably done 15 turnaround time ≈ time to start next I/O closed loop: faster turnaround time → program requests CPU sooner turnaround time ≈ how long does user wait

  19. throughput run A … time lost not starting I/O early as possible time lost due to cold caches also other considerations: non-context switch CPU utilization = 16 (2 units) run A (3 units) run B context switch(each .5 units) (3 units) throughput: useful work done per unit time 3 + 3 + 2 3 + . 5 + 3 + . 5 + 2 = 88%

  20. fairness run A easy to answer — but formal defjnition? two timelines above; which is fairer? assumption: one program per user run B run A run B run B timeline 1 run A run B run A timeline 2 run B run A 17

  21. fairness run A easy to answer — but formal defjnition? two timelines above; which is fairer? assumption: one program per user run B run A run B run B timeline 1 run A run B run A timeline 2 run B run A 17

  22. two trivial scheduling algorithms fjrst-come fjrst served (FCFS) round robin (RR) 18

  23. scheduling example assumptions multiple programs become ready at almost the same time alternately: became ready while previous program was running …but in some order that we’ll use e.g. our ready queue looks like a linked list 19

  24. two trivial scheduling algorithms fjrst-come fjrst served (FCFS) round robin (RR) 20

  25. fjrst-come, fjrst-served simplest(?) scheduling algorithm no preemption — run program until it can’t suitable in cases where no context switch e.g. not enough memory for two active programs 21

  26. arrival order: A , B , C arrival order: B , C , A fjrst-come, fjrst-served (FCFS) A 0 ( A ), 24 ( B ), 28 ( C ) turnaround times: (mean=27.7) 24 ( A ), 28 ( B ), 31 ( C ) B C 0 30 10 20 30 waiting times: (mean=3.7) 7 ( A ), 0 ( B ), 4 ( C ) turnaround times: (mean=14) 31 ( A ), 4 ( B ), 7 ( C ) waiting times: (mean=17.3) 10 20 3 process CPU time needed A 24 B 4 C A (AKA “fjrst in, fjrst out” (FIFO)) CPU-bound B, C I/O bound or interactive A B C 0 22

  27. arrival order: A , B , C arrival order: B , C , A fjrst-come, fjrst-served (FCFS) A turnaround times: (mean=27.7) 24 ( A ), 28 ( B ), 31 ( C ) B C 0 waiting times: (mean=17.3) 10 20 30 waiting times: (mean=3.7) 7 ( A ), 0 ( B ), 4 ( C ) turnaround times: (mean=14) 31 ( A ), 4 ( B ), 7 ( C ) 0 ( A ), 24 ( B ), 28 ( C ) 20 30 C process CPU time needed A 24 B 4 3 (AKA “fjrst in, fjrst out” (FIFO)) A B C 0 10 22 A ∼ CPU-bound B, C ∼ I/O bound or interactive

  28. arrival order: B , C , A fjrst-come, fjrst-served (FCFS) A 0 ( A ), 24 ( B ), 28 ( C ) turnaround times: (mean=27.7) 24 ( A ), 28 ( B ), 31 ( C ) B C 0 30 10 20 30 waiting times: (mean=3.7) 7 ( A ), 0 ( B ), 4 ( C ) turnaround times: (mean=14) 31 ( A ), 4 ( B ), 7 ( C ) waiting times: (mean=17.3) 20 (AKA “fjrst in, fjrst out” (FIFO)) C process CPU time needed A 24 B 4 3 10 arrival order: A , B , C A B C 0 22 A ∼ CPU-bound B, C ∼ I/O bound or interactive

  29. arrival order: B , C , A fjrst-come, fjrst-served (FCFS) A 0 ( A ), 24 ( B ), 28 ( C ) turnaround times: (mean=27.7) 24 ( A ), 28 ( B ), 31 ( C ) B C 0 30 10 20 30 waiting times: (mean=3.7) 7 ( A ), 0 ( B ), 4 ( C ) turnaround times: (mean=14) 31 ( A ), 4 ( B ), 7 ( C ) waiting times: (mean=17.3) 20 (AKA “fjrst in, fjrst out” (FIFO)) C process CPU time needed A 24 B 4 3 10 arrival order: A , B , C A B C 0 22 A ∼ CPU-bound B, C ∼ I/O bound or interactive

  30. fjrst-come, fjrst-served (FCFS) 0 0 ( A ), 24 ( B ), 28 ( C ) turnaround times: (mean=27.7) 24 ( A ), 28 ( B ), 31 ( C ) B C A 10 30 20 30 waiting times: (mean=3.7) 7 ( A ), 0 ( B ), 4 ( C ) turnaround times: (mean=14) 31 ( A ), 4 ( B ), 7 ( C ) waiting times: (mean=17.3) 20 (AKA “fjrst in, fjrst out” (FIFO)) 3 process CPU time needed A 24 B 4 C 22 10 arrival order: A , B , C A B C 0 A ∼ CPU-bound B, C ∼ I/O bound or interactive arrival order: B , C , A

  31. fjrst-come, fjrst-served (FCFS) 0 0 ( A ), 24 ( B ), 28 ( C ) turnaround times: (mean=27.7) 24 ( A ), 28 ( B ), 31 ( C ) B C A 10 30 20 30 waiting times: (mean=3.7) 7 ( A ), 0 ( B ), 4 ( C ) turnaround times: (mean=14) 31 ( A ), 4 ( B ), 7 ( C ) waiting times: (mean=17.3) 20 (AKA “fjrst in, fjrst out” (FIFO)) 3 process CPU time needed A 24 B 4 C 22 10 arrival order: A , B , C A B C 0 A ∼ CPU-bound B, C ∼ I/O bound or interactive arrival order: B , C , A

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend