You are on page 1of 44

Lecture 6

CPU Scheduling

14 September, 2010

1
ready running

new blocked exit

2
pre-emptive
vs.
non pre-emptive

3
CPU-bound
vs.
I/O-bound

4
(process states)

5
6
7
PA

PB

PC

8
C B C B C A B A B A

(CPU states)

9
CPU Utilization

C B C B C A B A B A

10
Throughput

C B C B C A B A B A

11
Response Time

C B C B C A B A B A

12
Turnaround Time

C B C B C A B A B A

13
Fairness

C B C B C A B A B A

C C C
B B B B
A A A

14
Balance

C B C B C A B A B A

15
Scheduling
Algorithms

16
FCFS
(non-preemptive)

Ready Queue

17
PA

PB

PC

18
A B C A

19
Round Robin
(preemptive)

Ready Queue

20
PA

PB

PC

21
A B C A A B C A A

22
Time Quantum
20 - 50ms

23
Shortest Job First
(non-preemptive)

Priority Queue

24
FCFS A B C D

SJF B C D A

25
Shortest Remaining Time First
(preemptive)

Priority Queue

26
Estimating
Remaining Time

27
Priority Scheduling
(preemptive)

28
Static
vs.
Dynamic Priority

29
Guidelines
for
Good Schedulers

30
1.
interactive jobs should
have higher priority than
CPU bound jobs

31
2.
CPU intensive jobs should
have be given larger time
quantum

32
3.
round robin is good for
response time but bad for
turnaround time

33
4.
shortest job first reduces
the turnaround time

34
(how to know if a job is
interactive? remaining
time on the job?)

35
join lower
level but
higher quanta

ready running
join highest
level queue
stay at
same/higher
level
new blocked exit

36
Multilevel Feedback Queue

37
interactive jobs remains on top

CPU intensive jobs sink to bottom

38
Linux Scheduler
Active Expired

0 0

1 1

: :

139 139

39
move to
expired list and
recompute priority

ready running

join active list at


stay in active list
default priority
at same priority

new blocked exit

40
Linux Static Priority
0

“real time” jobs

default priority 120


99

user jobs
139
41
Linux Static Priority
0

“real time” jobs

time quantum
99
-20 800ms
nice

user jobs
139 +19 5ms
42
Linux Dynamic Priority
-5

sleep time -
run time

+5
43
Swap Active <-> Expired
Active Expired

0 0

1 1

: :

139 139

44

You might also like