1 / 36

Chapter 2.2 : Scheduling

Chapter 2.2 : Scheduling. Objectives. To introduce CPU scheduling, which is the basis for multiprogrammed operating systems To describe various CPU-scheduling algorithms To discuss evaluation criteria for selecting a CPU-scheduling algorithm for a particular system. Scheduling.

mickey
Télécharger la présentation

Chapter 2.2 : 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. Chapter 2.2: Scheduling

  2. Objectives • To introduce CPU scheduling, which is the basis for multiprogrammed operating systems • To describe various CPU-scheduling algorithms • To discuss evaluation criteria for selecting a CPU-scheduling algorithm for a particular system

  3. Scheduling • scheduling: share CPU among processes • scheduling should: • be fair • all processes must be similarly affected • no indefinite postponement • “aging” as a possible solution • adjust priorities based on waiting time for resource • max. possible number of processes per unit time • reduce response time for interactive users

  4. Scheduling • priorities should be used • not fail even under very heavy load • e.g. accept no new processes to system • e.g. lower quantum

  5. Scheduling Criteria • I/O bound • CPU bound • interactive / batch • importance of quick response • priority • real execution time • time to completion

  6. Scheduling • preemptive x non-preemptive scheduling • preemptive • high cost of context switching • to be effective, there must be a sufficient amount of processes ready to run in memory

  7. Priorities • static x dynamic priorities • static priorities • fixed during execution • easy to implement • not efficient • dynamic priorities • change based on environment changes • harder to implement + more CPU time • enhances response times

  8. Scheduling Techniques

  9. Deadline Scheduling • order processes based on their ending times • useless if process is not completed on time • process must declare all resource requests beforehend • may not be possible • plan resource allocation based on ending times • new resources may become available

  10. FIFO Scheduling • simplest technique • order based on arrival times • non-preemptive • processes with short service times wait unnecessarily because of processes requring long service times • ineffective for interactive processes • response times may be too long • ineffective for I/O bound proceses • I/O ports may be available while the process waits for a CPU bound process to complete FIFO usually used together with other techniques

  11. P1 P2 P3 0 24 27 30 Example: FIFO Scheduling ProcessBurst Time P1 24 P2 3 P3 3 • Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: • Waiting time for P1 = 0; P2 = 24; P3 = 27 • Average waiting time: (0 + 24 + 27)/3 = 17

  12. P2 P3 P1 0 3 6 30 Example: FIFO Scheduling Suppose that the processes arrive in the order: P2 , P3 , P1 • The Gantt chart for the schedule is: • Waiting time for P1 = 6;P2 = 0; P3 = 3 • Average waiting time: (6 + 0 + 3)/3 = 3 • Much better than previous case • Convoy effect - short process behind long process • Consider one CPU-bound and many I/O-bound processes

  13. Scheduling Example

  14. 5 0 10 15 20 A B C D E Example: FIFO Scheduling

  15. ready queue new process end CPU suspend queue Round-Robin Schedulling

  16. Round-Robin Schedulling • FIFO-like • assign CPU to processes for fixed time units in turn • preemptive • quantum = time slice • if not completed within quantum: move to end of queue • effective for interactive processes • has context switching

  17. Round-Robin Schedulling • selection of quantum is critical • has effect on performance of system • short x long • fixed x variable • same x different for each user • if too long quantum becomes FIFO • if too short quantum too much time for context switches • correct quantum sizes different for different types of systems

  18. Scheduling Example

  19. 5 0 10 15 20 A B C D E Example: Round-Robin Scheduling

  20. Shortest-Job-First Scheduling • non-preemptive • order based on shortest time to completion • decreased average waiting times compared to FIFO • better service for short jobs • not suitable for interactive processes • total running time must be known beforehand • user provides estimate • if requires more than estimate, stop process and run later • if jobs repeat, may know running time

  21. P3 P2 P4 P1 3 9 16 24 0 Example of SJF ProcessArTimeBurst Time P10.0 6 P2 2.0 8 P34.0 7 P45.0 3 SJF scheduling chart • Average waiting time = (3 + 16 + 9 + 0) / 4 = 7

  22. Scheduling Example

  23. 5 0 10 15 20 A B C D E Example of SJF

  24. Shortest Time Remaining First Scheduling • preemptive version of previous technique • good performance for time-sharing systems • run process with least time remaining to completion • consider new arrivals too • a running process may be preempted by a new, short process • total running time must be known beforehand • more time wasted • used / remaining time calculations • context switching

  25. P1 P3 P4 P2 P1 0 5 1 10 17 26 Example of STRFS • Now we add the concepts of varying arrival times and preemption to the analysis ProcessAarriArrival TimeTBurst Time P10 8 P2 1 4 P32 9 P43 5 • Preemptive STRFS Gantt Chart • Average waiting time = [(10-1)+(1-1)+(17-2)+5-3)]/4 = 26/4 = 6.5 msec

  26. Scheduling Example

  27. 5 0 10 15 20 A B C D E Example of STRFS

  28. Priority Scheduling • A priority number (integer) is associated with each process • The CPU is allocated to the process with the highest priority (smallest integer  highest priority) • Preemptive • Nonpreemptive • SJF is priority scheduling where priority is the inverse of predicted next CPU burst time

  29. P1 P5 P3 P4 P2 0 6 1 16 18 19 Example of Priority Scheduling ProcessA arri Burst TimeTPriority P1 10 3 P2 1 1 P32 4 P41 5 P5 5 2 • Priority scheduling Gantt Chart • Average waiting time = 8.2 msec

  30. Priority Scheduling • Problem  Starvation – low priority processes may never execute • Solution  Aging – as time progresses increase the priority of the process

  31. Highest Response Ratio Next Scheduling • Nonpreemptive • A solution method to the long jobs in SJF • Dynamic priority is calculated to find next job to execute  priority = (burst time + waiting time) / (burst time) ?

  32. level 1 (round-robin) CPU Level 2 (round-robin) Level 3 (round-robin) level n (FIFO) Multilevel Queues Scheduling

  33. Multilevel Queues Scheduling • new process to end of level 1 • round-robin (or any other) within levels • if not completed within quantum, go to end of lower level • limited number of levels • in last level, round-robin instead of FIFO • short, new jobs completed in a short time • in some systems, longer quantum at lower levels

  34. Multilevel Queues Scheduling

  35. Multilevel Queues Scheduling

  36. Multilevel Queues Scheduling • processes at higher level queues finished before those in lower levels can be run • a running process may be preempted by a process arriving to a higher level • in some systems stay in same queue for a few rounds • e.g. at lower level queues

More Related