lecture 6 cpu scheduling - nus computing

50
Lecture 6 CPU Scheduling 16 September, 2011 1

Upload: others

Post on 27-Feb-2022

7 views

Category:

Documents


0 download

TRANSCRIPT

Lecture 6CPU Scheduling

16 September, 2011

1

new

ready running

blocked exit

2

batchvs.

interactivevs.

real-time3

CPU-boundvs.

I/O-bound

4

pre-emptivevs.

non pre-emptive

5

(process states)

6

7

8

PA

PB

PC

9

B B B BC C AC A A

(CPU states)

10

CPU Utilization

B B B BC C AC A A

11

Throughput

B B B BC C AC A A

12

Response Time

B B B BC C AC A A

13

Turnaround Time

B B B BC C AC A A

14

Fairness

C C CB B B BA A A

B B B BC C AC A A

15

Balance

B B B BC C AC A A

16

Scheduling Algorithms

17

FCFS(non-preemptive)

Ready Queue

18

PA

PB

PC

19

AA B C

20

Round Robin(preemptive)

Ready Queue

21

PA

PB

PC

22

A B C A A B C A A

23

Long Time Quantumvs.

Short Time Quantum

24

Time Quantum20 - 50ms

25

Shortest Job First(non-preemptive)

Priority Queue

26

A B C D

AB C D

FCFS

SJF

27

Priority Queue

Shortest Remaining Time First(preemptive)

28

EstimatingRemaining Time

29

Priority Scheduling(preemptive)

k

1

0

:

30

Staticvs.

Dynamic Priority

31

Guidelines for

Good Schedulers

32

1. interactive jobs should

have higher priority than CPU bound jobs

33

2. CPU intensive jobs should

be given larger time quantum

34

3. round robin is good for

response time but bad for turnaround time

35

4. shortest job first reduces

the turnaround time

36

(how to know if a job is interactive? remaining

time on the job?)

37

Multilevel Feedback Queue

k

1

0

:

38

new

ready running

blocked exit

join highestlevel queue

stay at same/higher

level

join lower level but

higher quanta

39

interactive jobs remains on top

CPU intensive jobs sink to bottom

40

1. interactive jobs should

have higher priority than CPU bound jobs

41

2. CPU intensive jobs should have be given larger time

quantum

42

3. round robin is good for

response time but bad for turnaround time

43

4. shortest job first reduces

the turnaround time

44

Linux Scheduler

139

1

0

:

139

1

0

:

ExpiredActive

45

new

ready running

blocked exit

join active list at default priority stay in active list

at same priority

move toexpired list and

recompute priority

46

Linux Static Priority0

99

139

“real time” jobs

user jobs

default priority 120

47

Linux Static Priority0

99

139

“real time” jobs

user jobs

nice

-20

+19

time quantum800ms

5ms48

Linux Dynamic Priority

slee

p tim

e -

run

time

-5

+549

Swap Active <-> Expired

139

1

0

:

139

1

0

:

ExpiredActive

50