1 / 18

CMT603

CMT603. Lecture 4 Scheduling-2. Contents. Last Week FCFS SJF Priority scheduling Round Robin Multi Level Queues Real Systems Linux XP. Priority Scheduling.

morse
Download Presentation

CMT603

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. CMT603 Lecture 4 Scheduling-2

  2. Contents • Last Week • FCFS • SJF • Priority scheduling • Round Robin • Multi Level Queues • Real Systems • Linux • XP

  3. Priority Scheduling • A priority is associated with each process,and the CPU is allocated to the processwith the highest priority. We assume thatlow numbers represent high priority. • May be preemptive or non-preemptive.

  4. Example: Priority Scheduling • Consider the following set of processes with their arrival times and the length of the CPU-burst time given in milliseconds • The arrival order of the processes is P1, P2, P3, P4, P5

  5. Average wait time= (6+0+16+18+1)/5 = 8.2 Example: Priority Scheduling P2 P5 P1 P3 P4 0 1 6 16 18 19

  6. Average wait time = (1+0+1+6+0)/5 = 1.6 Exercise T=0 T=5 T=6 T=8 T=9 T=16 T=10 T=11 - - - - 8 3 3 1 1 - - - - - - 2 2 1 - - 1 1 1 5 - P1 P2 P1 P3 P5 P4 0 5 6 9 11 16 17

  7. Analysis of Priority Scheduling • May leave some low-priority processes waiting indefinitely for CPU • Starvation. • Aging – a technique of gradually increasing the priority of processes that have waited for a long time.

  8. Round Robin • Similar to FCFS but with preemption. • Have a time quantum (time slice). • Let the first process in the queue run until it exceeds the time quantum, then run the next process. • The arrival order of the processes is P1,P2,P3

  9. Example: Round Robin Time Quantum = 5 milliseconds P1 P2 P3 P1 P3 P1 P1 P1 0 5 8 13 18 22 36 Average waiting Time = (12+5+13)/3 = 10 Time Quantum = 24 milliseconds P1 P2 P3 0 24 27 36 Average waiting Time = (0+24+27)/3 = 17 Turns into FCFS scheduling

  10. Exercise: Round Robin Time quantum = 2 milliseconds P1 P1 P1 P2 P3 P1 P2 P3 P1 P3 P1 P3 P1 P3 P1 P1 P1 P1 P1 8 0 2 4 6 9 11 13 15 17 19 22 23 36 Average waiting Time = (12+6+13)/3 = 10.33 What if context-switch time = 1 millisecond? Total context-switch time =12

  11. Analysis of Round Robin Scheduling • Very small quantum - large context switch overhead. • Very big quantum - turns into FCFS. • The time quantum should be large with respect to the context-switch time. • In most modern OSs • Quantum time range: 10-100 milliseconds • Context-switch time: <10 microseconds

  12. Scheduling algorithms. • FCFS, SJF, Priority, Round Robin. • Preemptive, Non preemptive • All Basic Algorithms • Real life systems have a mix of these approaches

  13. Multi level Queues • Separate scheduling within queues • Scheduling between queues Foreground processes (Round Robin) Queue Scheduler (Priority) Background processes (FCFS)

  14. Linux • Priority Queue • 0-99 real time • 100-140 nice • Higher priority = longer time slice • Once time slice is expired, wait for all other slices to expire

  15. XP • 32 Level Priority Algorithm in two classes • 1-15 Variable • 16-31 Real time • Also 0 for memory management • FIFO queue in each level. • When Quantum runs out in Variable Class priority drops • Limits CPU intensive processes • Foreground windows +3 priority

  16. Summary • Last Week • FCFS • SJF • Priority scheduling • Round Robin • Multi Level Queues • Real Systems • Linux • XP

  17. Group Discussion • For 5-10 minutes, discuss how you would design a scheduling algorithm for a Desktop PC, using multilevel queues.

  18. Exercise sheet

More Related