Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CMT603 Lecture 4 Scheduling-2. Contents Last Week –FCFS –SJF Priority scheduling Round Robin Multi Level Queues Real Systems –Linux –XP."— 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 process with the highest priority. We assume that low 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 ProcessArrival TimePriorityBurst time P10310 P2011 P3042 P4051 P5025

5 Example: Priority Scheduling Proc ess Arrival Time Prio rity Burst time P10310 P2011 P3042 P4051 P5025 P2P5P1P3P Average wait time= ( )/5 = 8.2

6 Exercise ProcessArrival TimePriorityBurst time P1038 P2511 P3842 P41051 P51125 P2P5P1P3P P1 T=5 T=6T=8T=9 8 T= T= T=11 T= Average wait time = ( )/5 = 1.6

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 ProcessArrival TimeBurst Time P1024 P203 P309

9 Example: Round Robin ProcessArrival TimeBurst Time P1024 P203 P309 Time Quantum = 5 milliseconds P1P2P3P1P3P Average waiting Time = ( )/3 = 10 Time Quantum = 24 milliseconds P1P2P3 Average waiting Time = ( )/3 = Turns into FCFS scheduling

10 Exercise: Round Robin ProcessArrival TimeBurst Time P1024 P203 P309 Time quantum = 2 milliseconds P1 P2 P What if context-switch time = 1 millisecond? Average waiting Time = ( )/3 = 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: 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) Background processes (FCFS) Queue Scheduler (Priority)

14 Linux Priority Queue –0-99 real time – 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


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

Similar presentations


Ads by Google