Professional Documents
Culture Documents
Operating Systems: Lecture 3: Process Scheduling Algorithms
Operating Systems: Lecture 3: Process Scheduling Algorithms
Maxim Shevertalov
Jay Kothari
William M. Mongan
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
• Waiting Time: A process can finish before the time quantum expires, and release the CPU.
– P1: (68-20)+(112-88) = 72
– P2: (20-0) = 20
– P3: (28-0)+(88-48)+(125-108) = 85
– P4: (48-0)+(108-68) = 88
• Completion Time:
– P1: 125
– P2: 28
– P3: 153
– P4: 112
• Average Waiting Time: (72+20+85+88)/4 = 66.25
• Average Completion Time: (125+28+153+112)/4 = 104.5
n 1 t n 1 n .
32
Predicting the Future
n 1 t n 1 n .
33
Examples of Exponential Averaging
=0
n+1 = n
– Recent history does not count
=1
– n+1 = tn
– Only the actual last CPU burst counts
• If we expand the formula, we get:
n+1 = tn+(1 - ) tn -1 + …
+(1 - )j tn -j + …
+(1 - )n +1 0
• What if there are too many short jobs to give reasonable response
time
– In UNIX, if load average is 100%, it’s hard to make progress
– Log a user out or swap a process out of the ready queue (long term
scheduler)