1 / 14

Operating Systems { week 06.a}

Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D. Operating Systems { week 06.a}. Short-term (CPU) scheduling (i). The short-term scheduler decides which process the CPU executes next

kurt
Download Presentation

Operating Systems { week 06.a}

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. Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D. Operating Systems{week 06.a}

  2. Short-term (CPU) scheduling (i) • The short-term scheduler decides which process the CPU executes next • The dispatcher gives control of the CPU to the process selected by the CPU scheduler: • Performs context switch • Switches to user mode • Jumps to the proper location in the user program to resume program execution

  3. Short-term (CPU) scheduling (ii) the dispatcher operates here

  4. CPU scheduling algorithms (i) • CPU scheduling requires an algorithm todetermine which process to dispatch next • Scheduling algorithms include: • First-Come, First-Served (FCFS) • Shortest-Job-First (SJF) • Round-Robin (RR) • Priority • Multilevel Queue (MQ)

  5. process CPU scheduling algorithms (ii) • Preemptive scheduling preempts a running process before itstime slice expires • Or it preempts a processbecause its time slice has expired • Non-preemptive scheduling gives a process exclusive uninterrupted access to the CPU for the entirety of its execution process process process

  6. CPU scheduling algorithms (iii) • Compare scheduling algorithms by measuring • CPU utilization – keep CPU as busy as possible • Throughput – maximize the number of processes that complete their execution per unit time • Turnaround time – minimize the elapsed time to fully execute a particular process • Waiting time – minimize the elapsed time a process waits in the ready queue

  7. P1 P2 P3 0 24 27 30 First-Come-First-Served (FCFS) • FCFS dispatches processesin the order they enterthe ready queue • FCFS is non-preemptive time

  8. P2 P3 P1 0 3 6 30 Shortest-Job-First (SJF) • SJF dispatches processes byselecting the process withthe lowest CPU burst time • SJF is non-preemptive (and predictive) time

  9. SJF with varied arrival times • What happenswhen processesarrive at differentarrival times? • Calculate the turnaround times and wait times for each process • Calculate the average turnaround time and average wait time

  10. P1 P2 P3 P2 P4 P1 11 16 0 2 4 5 7 Preemptive SJF • Same as SJF, but anew process maypreempt therunning process time

  11. Limitations of SJF (i) • SJF is the optimal solution • The problem with SJF is the inability toknow the required CPU burst times • Apply a prediction algorithm that usesprevious CPU burst times • Algorithm uses exponential averaging: • tn = actual length of the nth CPU burst • τn+1 = predicted value for the next CPU burst • τn+1 = α tn + (1 – α) τn , where 0 < α < 1

  12. Limitations of SJF (ii) α is ½

  13. Limitations of SJF (iii) α is ¾ α is ½ α is ¼

  14. Practice! • Apply the FCFS, SJF, and Preemptive SJF scheduling algorithms to this table: • Calculate the wait and turnaround times ofeach process, as well as overall averages recalculate using context switch time tcs = 20 μs

More Related