Lecture 4 Scheduling-2
Contents
Last Week
FCFS SJF
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.
P4
P5
0
0
5
2
1
5
Proc ess P1 P2 P3 P4 P5
Arrival Time 0 0 0 0 0
Prio rity 3 1 4 5 2
Burst time 10 1 2 1 5
P2
0 1
P5
6
P1
16
P3 P4
18 19
Exercise
Process P1 P2 P3 P4 Arrival Time Priority Burst time 0 5 8 10 3 1 4 5 8 1 2 1
T=16
P5
11
8 3 3 1 - - - 1 - - - - - 2 2 1 - 1 1 1 5 -
T=9
T=10
T=11
P1
0 5
P2 P1
6 9
P3
11
P5
P4
16 17
Aging a technique of gradually increasing the priority of processes that have waited for a long time.
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.
P1 P2 P3
0 0 0
24 3 9
P1 P3 P1
18 22
P1
P1
36
P1
0
P2
24 27
P3
36
P1
P2 P3
0
0 0
24
3 9
Average waiting Time = (12+6+13)/3 = 10.33 What if context-switch time = 1 millisecond? Total context-switch time =12
Scheduling algorithms.
FCFS, SJF, Priority, Round Robin. Preemptive, Non preemptive
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
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
Summary
Last Week
FCFS SJF
Group Discussion
For 5-10 minutes, discuss how you would design a scheduling algorithm for a Desktop PC, using multilevel queues.
Exercise sheet