scheduling - illinois institute of technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than...

134
CS 450: Operating Systems Michael Saelee <[email protected]> Scheduling 1

Upload: vuongphuc

Post on 16-Apr-2018

229 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

CS 450: Operating SystemsMichael Saelee <[email protected]>

Scheduling

1

Page 2: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

§Overview

2

Page 3: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

scheduling: policies & mechanisms used to allocate a resource to some set of entities

3

Page 4: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

resource & entities: CPU & processes

other possibilities:

- resources: memory, I/O bus/devices

- entities: threads, users, groups

4

Page 5: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

policy: high-level “what”

- aka scheduling disciplines

mechanism: low-level “how”

- e.g., interrupts, context switch

5

Page 6: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

(we’ll start with policy first)

6

Page 7: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

essential idea:

- CPU(s) are a limited resource

- efficiently allow for time-sharing of CPU(s) amongst multiple processes

- enables concurrency on a single CPU

7

Page 8: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

at a high level (policy), only concern ourselves with macro process state

one of running, ready, or blocked

8

Page 9: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

running = consuming CPU

ready = “runnable”, but not running

blocked = not runnable (e.g., waiting for I/O)

9

Page 10: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Ready

Running

Blocked

I/O request(trap/syscall)

scheduled

I/O completion

creation

completion

Ready Blocked

swap in/out swap in/out

preemption

10

Page 11: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

preemptive scheduling

☑ running → ready transition

11

Page 12: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

non-preemptive scheduling

☒ running → ready transition

i.e., not = batch!

12

Page 13: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

domain of the “swapper” — separate from the CPU scheduler

- frequency in seconds vs. ms

- ignore for now

Ready Blocked

swap in/out swap in/out

13

Page 14: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Ready

Runningscheduled

convenient to envision a ready queue/set

scheduling policy is used to select the next running process from the ready queue

14

Page 15: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

policies vary by:

1. preemptive vs. non-preemptive

2. factors used in selecting a process

3. goals; i.e., why are we selecting a given process?

15

Page 16: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

scheduling goals are usually predicated on optimizing certain scheduling metrics

— can be provable or based on heuristics

16

Page 17: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

§Scheduling Metrics

17

Page 18: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

metrics we’ll be concerned with:

- turnaround time

- wait time

- response time

- throughput

- utilization

18

Page 19: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

turnaround time:

Tturnaround = Tcompletion - Tcreation

i.e., total time to complete process

19

Page 20: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

turnaround time depends on much more than the scheduling discipline!

- process runtime

- process I/O processing time

- how many CPUs available

- how many other processes need to run

20

Page 21: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

wait time: time spent in ready queue

i.e., how long does the scheduler force a runnable process to wait for a CPU

- better gauge of scheduler’s effectiveness

21

Page 22: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

turnaround & wait time are measured over the course of an entire process — sometimes refer to as the “job”

- not a very useful metric for interactive processes

- which typically alternate between CPU & I/O bursts, indefinitely

22

Page 23: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

5.4 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Feb 2, 2005

Alternating Sequence of CPU And I/O BurstsAlternating Sequence of CPU And I/O Bursts

“bursty” execution

23

Page 24: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

5.5 Silberschatz, Galvin and Gagne ©2005Operating System Concepts – 7th Edition, Feb 2, 2005

Histogram of CPUHistogram of CPU--burst Timesburst Times

burst length histogram

24

Page 25: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

can take measurements per-burst

i.e., from first entry into ready queue to completion or transition to blocked

- burst turnaround time, aka response time

- burst wait time

25

Page 26: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

throughput:

number of completed jobs or bursts per time unit (e.g., N/sec)

26

Page 27: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

utilization:

% of time CPU is busy running jobs

- note: CPU can be idle if there are no active jobs or if all jobs are blocked!

27

Page 28: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

another (subjective) metric: fairness

- what does this mean?

- how to measure it?

- is it useful?

28

Page 29: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

§Scheduling Policies

29

Page 30: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

1. First Come First Served

30

Page 31: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Process Arrival Time Burst Time

P1 0 24

P2 0 3

P3 0 3

Wait times: P1 = 0, P2 = 24, P3 = 27Average: (0+24+27)/3 = 17

P1 P2 P3

24 27 300 “Gantt chart”

31

Page 32: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Convoy Effect32

Page 33: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Process Arrival Time Burst Time

P3 0 3

P2 0 3

P1 0 24

P3 P2 P1

3 6 300

Wait times: P1 = 6, P2 = 3, P3 = 0Average: (6+3+0)/3 = 3

33

Page 34: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

2. Shortest Job First

34

Page 35: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

0

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

P2 waits

P3 waits

P4 waits

P1 P3 P2 P4

Non-preemptive SJF

35

Page 36: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Wait times:P1 = 0, P2 = 6, P3 = 3, P4=7Average: (0+6+3+7)/4 = 4

P2 waits

P3 waits

P4 waits

P1 P3 P2 P4

0

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

36

Page 37: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

can we do better?

37

Page 38: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Yes! (theoretically): Preemptive SJF

a.k.a. Shortest-Remaining-Time-First

38

Page 39: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

P1 P3 P4

0

P2 P2 P1

P1 waits

P2 waits

P4 waits

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

39

Page 40: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

P1 P3 P4

0

P2 P2 P1

P1 waits

P2 waits

P4 waits

Wait times: P1 = 9, P2 = 1, P3 = 0, P4 = 2Average: (9+1+0+2)/4 = 3

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

40

Page 41: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

SJF/SRTF are greedy algorithms;

i.e., they always select the local optima

greedy algorithms don’t always produce globally optimal results (e.g., hill-climbing)

41

Page 42: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

consider 4 jobs arriving at t=0, with burst lengths t0, t1, t2, t3

avg. wait time if scheduled in order?

=3t0 + 2t1 + t2

4

42

Page 43: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

— a weighted average; clearly minimized by running shortest jobs first.

I.e., SJF/PSJF are provably optimal w.r.t. wait time!

=3t0 + 2t1 + t2

4

43

Page 44: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

at what cost?

… potential starvation!

(possible for both non-preemptive & preemptive variants)

44

Page 45: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

also, we’ve been making two simplifying assumptions:

1. context switch time = 0

2. burst lengths are known in advance

45

Page 46: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

(1) will be dealt with later;

(2) is a serious problem!

46

Page 47: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

typically predict future burst lengths based on past job behavior

- simple moving average

- exponentially weighted moving average (EMA)

47

Page 48: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Observed: ρn-1

Estimated: σn-1

Weight (α): 0 ≤ α ≤ 1

EMA: σn = α⋅ρn-1 + (1–α)⋅σn-1

48

Page 49: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Actual Avg (3) Error EMA Error4 5.00 1.00 5.00 1.00 EMA Alpha:EMA Alpha: 0.25 4.00 1.00 4.80 0.205 4.50 0.50 4.84 0.166 4.67 1.33 4.87 1.1313 5.33 7.67 5.10 7.9012 8.00 4.00 6.68 5.3211 10.33 0.67 7.74 3.266 12.00 6.00 8.39 2.397 9.67 2.67 7.92 0.925 8.00 3.00 7.73 2.73

Avg err: 2.78 2.50

0

2.6

5.2

7.8

10.4

13.0

Actual Avg (3) EMA

49

Page 50: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

how to deal with starvation?

one way: enforce fairness

50

Page 51: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

3. Round Robin: the “fairest” of them all

- FIFO queue

- each job runs for max time quantum

- if unfinished, re-enter queue at back

51

Page 52: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Given time quantum q and n jobs:

- max wait time = q ∙ (n – 1)

- each job receives 1/n timeshare

52

Page 53: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

P1 waits

P2 waits

P1 waits

P2 waits

P3 waits

P4 waits P4 waits

P1 P3

0

P2 P1 P4 P2 P1 P4

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

Round Robin, q=3

53

Page 54: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

P1 waits

P2 waits

P1 waits

P2 waits

P3 waits

P4 waits P4 waits

P1 P3

0

P2 P1 P4 P2 P1 P4

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

Wait times: P1 = 8, P2 = 8, P3 = 5, P4 = 7Average: (8+8+5+7)/4 = 7

54

Page 55: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

Avg. Turnaround Avg. Wait Time

RR q=1 9.75 5.75

RR q=3 11 7

RR q=4 9 5

RR q=7 8.75 4.75

55

Page 56: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

Avg. Turnaround Avg. Wait Time

RR q=1 20.25 13.25

RR q=3 16.25 11.25

RR q=4 11.50 7.25

RR q=7 10.25 6.25

(CST=1)

56

Page 57: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

Throughput Utilization

RR q=1 0.125 0.500

RR q=3 0.167 0.667

RR q=4 0.190 0.762

RR q=7 0.200 0.800

(CST=1)

57

Page 58: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

q large ⇒ FIFO

q small ⇒ big CST overhead

58

Page 59: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

generally, try to tune q to help tune responsiveness (i.e., of interactive processes)

may use:

- predetermined max response threshold

- median of EMAs

- process profiling

59

Page 60: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR permits CPU-hungry jobs to run periodically, but prevents them from monopolizing the system (compare to FCFS and SJF)

… but also introduces inflexible systemic overhead: constant context switching

60

Page 61: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Fairness is overrated!

61

Page 62: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Can exercise more fine-grained control by introducing a system of arbitrary priorities

- computed and assigned to jobs dynamically by scheduler

- highest (current) priority goes next

62

Page 63: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

SJF is an example of a priority scheduler!

- jobs are weighted using a burst-length prediction algorithm (e.g., EMA)

- priorities may vary over job lifetimes

63

Page 64: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Recall: SJF is prone to starvation

Common issue for priority schedulers

- combat with priority aging

64

Page 65: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

4. Highest Penalty Ratio Next

- example of a priority scheduler that uses aging to avoid starvation

65

Page 66: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Two statistics maintained for each job:

1. total CPU execution time, t

2. “wall clock” age, T

66

Page 67: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Priority, “penalty ratio” = T / t

- ∞ when job is first ready

- decreases as job receives CPU time

67

Page 68: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

HPRN in practice would incur too many context switches (due to very short bursts)

— likely institute minimum burst quanta

68

Page 69: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

5. Selfish RR

- example of a more sophisticated priority based scheduling policy

69

Page 70: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

priority ↑ α

priority ↑ β

β = 0 : RR

β ≥ (α ≠ 0) : FCFS

β > (α = 0) : RR in batches

α > β > 0 : “Selfish” (ageist) RR

active (RR)CPU

holdingarriving

70

Page 71: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Another problem (on top of starvation) possibly created by priority-based scheduling policies: priority inversion

71

Page 72: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Process Priority StateP1 High ReadyP2 Mid ReadyP3 Mid ReadyP4 Low Ready

72

Page 73: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

requestall

ocate

d

Process Priority StateP1 High RunningP2 Mid ReadyP3 Mid ReadyP4 Low Ready

Resource

P1 P2 P4P3

73

Page 74: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Process Priority StateP1 High BlockedP2 Mid ReadyP3 Mid ReadyP4 Low Ready

request

P1 P2 P4

Resource

P3

alloc

ated

(mutually exclusive allocation)

74

Page 75: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Process Priority StateP1 High BlockedP2 Mid RunningP3 Mid ReadyP4 Low Ready

request

P1 P2 P4

Resource

P3

alloc

ated

(mutually exclusive allocation)

75

Page 76: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

request

P1 P4

Resource

P3

alloc

ated

Process Priority StateP1 High BlockedP2 Mid DoneP3 Mid RunningP4 Low Ready

(mutually exclusive allocation)

76

Page 77: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

request

P1 P4

Resourceall

ocate

d

Process Priority StateP1 High BlockedP2 Mid DoneP3 Mid DoneP4 Low Running

(mutually exclusive allocation)

77

Page 78: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

request

P1

Resource

Process Priority StateP1 High BlockedP2 Mid DoneP3 Mid DoneP4 Low Done

(mutually exclusive allocation)

78

Page 79: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

P1

Resourceallocated

Process Priority StateP1 High ReadyP2 Mid DoneP3 Mid DoneP4 Low Done

(mutually exclusive allocation)

79

Page 80: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

P1

Resourceallocated

(mutually exclusive allocation)

Process Priority StateP1 High RunningP2 Mid DoneP3 Mid DoneP4 Low Done

80

Page 81: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

priority inversion: a high priority job effectively takes on the priority of a lower-level one that holds a required resource

81

Page 82: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

high profile case study: NASA Pathfinder

- spacecraft developed a recurring system failure/reset

- occurred after deploying data-gathering robot to surface of Mars

82

Page 83: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

culprits:

- flood of meteorological data

- low priority of related job: ASI/MET

- a shared, mutually exclusive resource (semaphore guarding an IPC pipe)

83

Page 84: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

high priority job (for data aggregation & distribution) — bc_dist — required pipe

- but always held by ASI/MET

- in turn kept from running by various mid-priority jobs

84

Page 85: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

scheduling job determined that bc_dist couldn’t complete per hard deadline

- declared error resulting in system reset!

- re-produced in lab after 18-hours of simulating spacecraft activities

85

Page 86: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

fix: priority inheritance

- job that blocks a higher priority job will inherit the latter’s priority

- e.g., run ASI/MET at bc_dist’s priority until resource is released

86

Page 87: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

how?

- enabling priority inheritance via semaphores (in vxWorks OS)

- (why wasn’t it on by default?)

- prescient remote (!) tracing & patching facilities built in to system

87

Page 88: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

why did NASA not foresee this?

“Our before launch testing was limited to the “best case” high data rates and science activities… We did not expect nor test the "better than we could have ever imagined" case.”

- Glenn Reeves Software team lead

88

Page 89: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

takeaways:

- scheduling bugs are hard to predict, track down, and fix

- priority inheritance provides a “solution” for priority inversion

- scheduling is rocket science!

89

Page 90: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

questions:

- w.r.t. priority inheritance:

- pros/cons?

- how to implement?

- w.r.t. priority inversion:

- detection? how else to “fix”?

- effect on non-real-time OS?

90

Page 91: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Even with the fine-grained control offered by a priority scheduler, hard to impose different sets of goals on groups of jobs

E.g., top-priority for system jobs, RR for interactive jobs, FCFS for batch jobs

91

Page 92: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

6. Multi-Level Queue (MLQ)

- disjoint ready queues

- separate schedulers/policies for each

92

Page 93: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Fixed priority

RR (small q)

FCFS

RR (larger q)

system

interactive

batch

normal

93

Page 94: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

requires queue arbitration strategy in place

94

Page 95: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Fixed priority

RR (small q)

FCFS

RR (larger q)

system

interactive

batch

normal

decr

easi

ng p

rior

ityapproach 1: prioritize top, non-empty queue

95

Page 96: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

Fixed priority

RR (small q)

FCFS

RR (larger q)

system

interactive

batch

normal

approach 2: aggregate time slices

30%

15%

50%

5%

96

Page 97: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

what processes go in which queues?

- self-assigned

- e.g., UNIX “nice” value

- “profiling” based on initial burst(s)

- CPU, I/O burst length

- e.g., short, intermittent CPU bursts ⇒ classify as interactive job

97

Page 98: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

classification issue: what if process characteristics change dynamically?

- e.g., photo editor: tool selection (interactive) ➞ apply filter (CPU hungry) ➞ simple edits (interactive)

98

Page 99: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

7. Multi-Level Feedback Queue

- supports movement between queues after initial assignment

- based on ongoing job accounting

99

Page 100: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=8)

RR (q=4)

e.g., 3 RR queues with different q

assignment based on q/burst-length fit

100

Page 101: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

P1

P1

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

101

Page 102: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

P1 RR (q=4)

RR (q=8)

P1

0

P2

P2

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

102

Page 103: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

P2 P1 RR (q=4)

RR (q=8)

P1

0

P2

P3

P3

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

103

Page 104: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

P2 P1 RR (q=4)

RR (q=8)

P1 P3

0

P2

P4

P4

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

104

Page 105: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

P4 P2 P1 RR (q=4)

RR (q=8)

P1 P3

0

P2 P4 P1

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

105

Page 106: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

P4 P2 RR (q=4)

P1 RR (q=8)

P1 P3

0

P2 P4 P1 P2

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

106

Page 107: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

P4 RR (q=4)

P1 RR (q=8)

P1 P3

0

P2 P4 P1 P2 P4

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

107

Page 108: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

P1 RR (q=8)

P1 P3

0

P2 P4 P1 P2 P4 P1

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

108

Page 109: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

P1 P3

0

P2 P4 P1 P2 P4 P1

Wait times: P1 = 9, P2 = 7, P3 = 0, P4 = 6Average: (9+7+0+6)/4 = 5.5 (vs 7 for RR, q=3)

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

109

Page 110: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

- following I/O, processes return to previously assigned queue

- when to move up?

- for RR, when burst ≤ q

110

Page 111: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

111

Page 112: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

Pf

Pf

112

Page 113: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf

Pf Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

113

Page 114: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf

Pf

Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

114

Page 115: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf

Pf Pf Pf

(I/O)

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

115

Page 116: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

116

Page 117: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf

Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

117

Page 118: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf

Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

118

Page 119: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

119

Page 120: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf

Pf

Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

120

Page 121: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf

Pf

Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

121

Page 122: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

122

Page 123: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf Pf

Pf

Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

123

Page 124: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf Pf

Pf

Pf Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

124

Page 125: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

RR (q=2)

RR (q=4)

RR (q=8)

0

Pf Pf Pf

(I/O)

Pf Pf Pf Pf

e.g., Pflaky arrives at t=0 CPU burst lengths = 7, 4, 1, 5 (I/O between)

125

Page 126: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

other possible heuristics:

- multi-queue hops due to huge bursts

- exponential backoff to avoid queue hopping

- dynamic queue creation for outliers

126

Page 127: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

§Scheduler Evaluation

127

Page 128: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

i.e., how well does a given scheduling policy perform under different loads?

typically, w.r.t. scheduling metrics: wait time, turnaround, utilization, etc.

128

Page 129: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

n.b., numerical metrics (e.g., wait time) are important, but may not tell the full story

e.g., how, subjectively, does a given scheduler “feel” under regular load?

129

Page 130: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

1. paper & pencil computations

2. simulations with synthetic or real-world job traces

3. mathematical models; e.g., queueing theory

4. real world testing (e.g., production OSes)

130

Page 131: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

(never fear, you’ll try your hand at all!)

131

Page 132: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

e.g., UTSA process scheduling simulator

- specify scheduling discipline and job details in configuration file

- bursts can be defined discretely, or using probability distributions

132

Page 133: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

output: Gantt charts & metrics

133

Page 134: Scheduling - Illinois Institute of Technologymoss.cs.iit.edu/cs450/slides/scheduling.pdf · than the scheduling discipline! ... SJF/SRTF are greedy algorithms; i.e., they always select

Computer ScienceScience

SJF vs. PSJF vs. RR, q=10 vs. RR, q=20processes: uniform bursts ≤ 20, CST = 1.0

Which is which?

134