+ All Categories
Home > Documents > Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

Date post: 18-Jan-2016
Category:
Upload: bryce-hood
View: 214 times
Download: 1 times
Share this document with a friend
Popular Tags:
47
Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi
Transcript
Page 1: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

Real-Time SchedulingCS 3204 – Operating Systems

Lecture 13

10/3/2006

Shahrooz Feizabadi

Page 2: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 2

Real-Time SystemsSystems that must service requests within a precise time constraint:

Air traffic control systems Railway switching systems Industrial automation Robotics Military

Generally, systems that must respond to external physical phenomena.

Page 3: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 3

Tracking System Example

Dynamic trajectory calculations False alarms Verification System response Real-time clock 687m error!

Page 4: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 4

System Resources

Different approaches to resource management: General-purpose OS

Extensible time horizon: all tasks eventually finish Similarly, elastic memory: demand paging Fairness Non-starvation

Real-Time system Fixed resources Tasks adjusted accordingly Predictability

Page 5: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 5

Schedulers

Preemptive / non-preemptive Static / dynamic On-line / off-line Optimal / heuristic Clairvoyance

Page 6: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 6

Real-Time Task Parameters

Ci

ai disi fi

t

Arrivaltime

Computationtime

starttime

finishtime

deadline

Page 7: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 7

Real-Time Tasks

Ci

ai disi fi

t

Ci

ai disi fi

t

Laxity (slack)

Deadline miss

x

Page 8: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 8

RMA Rate Monotonic Algorithm Static Preemptive Fixed-priority assignment Periodic tasks Guarantee-based Hard real-time correctness – all

deadlines always met

Page 9: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 9

RMA (continued)

RMA: Assign unique priorities, in descending order, to tasks ordered by ascending periods: the shorter the period, the higher the priority.

Page 10: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 10

RMA – Example

Task T C P

A 5 1

B

C

A

50 10 15 20 25

Assume deadline equals period (T).

Page 11: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 11

RMA – Example

Task T C P

A 5 1

B 9 3

C

A

50 10 15 20 25

B

Page 12: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 12

RMA – Example

Task T C P

A 5 1

B 9 3

C 12 2

A

50 10 15 20 25

B

C

Page 13: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 13

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 14: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 14

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 15: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 15

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 16: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 16

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 17: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 17

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

A preempts C

Page 18: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 18

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 19: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 19

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 20: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 20

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

A preempts B

Page 21: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 21

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

C arrives

Page 22: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 22

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 23: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 23

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 24: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 24

RMA – Example

Task T C P

A 5 1 3

B 9 3 2

C 12 2 1

A

50 10 15 20 25

B

C

Page 25: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 25

RMA (continued)

How far can we push this? Constraints

Number of tasks? Periods? Computational times?

Page 26: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 26

Processor Utilization FactorFraction of CPU time spent in execution of tasks:

Otherwise stated: sum of the individual relative load contribution of each task in the task-set.

Provides an indication of system-wide computational load.

Page 27: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 27

Feasibility Test

RMA guarantee: No deadlines will be missed under rate monotonic scheduling if the following condition holds:

Page 28: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 28

Feasibility Test (continued)

Note that:

That is, any task-set with a CPU utilization factor of 69% or less is schedulable under RMA

Sufficient, but not necessary condition

Page 29: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 29

Optimality

RMA is an optimal fixed-priority assignment algorithm: no other fixed-priority algorithms can schedule a task set that cannot be scheduled under RMA.

Page 30: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 30

EDF

Earliest Deadline First Earlier the deadline, higher the priority. Dynamic assignment On-line No periodicity assumptions – can

schedule aperiodic tasks.

Page 31: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 31

EDF – Example

Task T C

A 4 1

B 8 4

C 12 3

50 10 15 20 25

Assume deadline equals period (T).

A

B

C

Hyper-period

Page 32: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 32

EDF – Example

Task T C

A 4 1

B 8 4

C 12 3

50 10 15 20 25

Assume deadline equals period (T).

A

B

C

Page 33: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 33

EDF – Example

Task T C

A 4 1

B 8 4

C 12 3

50 10 15 20 25

Assume deadline equals period (T).

A

B

C

Page 34: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 34

EDF – Example

Task T C

A 4 1

B 8 4

C 12 3

50 10 15 20 25

Assume deadline equals period (T).

A

B

C

Lexical order tie breaker

Page 35: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 35

EDF – Example

Task T C

A 4 1

B 8 4

C 12 3

50 10 15 20 25

Assume deadline equals period (T).

A

B

C

Page 36: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 36

EDF – Example

Task T C

A 4 1

B 8 4

C 12 3

50 10 15 20 25

Assume deadline equals period (T).

A

B

C

Page 37: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 37

EDF – Example

Task T C

A 4 1

B 8 4

C 12 3

50 10 15 20 25

Assume deadline equals period (T).

A

B

C

Page 38: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 38

EDF – Example

Task T C

A 4 1

B 8 4

C 12 3

50 10 15 20 25

Assume deadline equals period (T).

A

B

C

Patternrepeats

Page 39: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 39

EDF Properties

Feasibility test:

U = 100% in example Bound theoretical Sufficient and necessary Optimal

Page 40: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 40

Overload

Hard real-time No deadlines misses. Dimension system to meet exact timing

requirements. Soft real-time

May encounter transient or sustained overload. Design algorithm to achieve desired temporal

behavior.

Page 41: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 41

Real-Time Overload Scheduling

Runtime uncertainty Dynamic system Aggregate demand exceeds capacity Fixed available bandwidth Must shed load Starvation Who survives?

Page 42: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 42

EDF Domino Effect

Deadline sole scheduling parameter

Page 43: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 43

EDF Domino Effect

X

X

X

Cascading deadline misses

Deadline sole scheduling parameter

Page 44: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 44

Load Shedding

Feasible schedule if any task excluded in example?

Selection criteria Fitness metric Second dimension: utility

Page 45: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 45

Load Shedding

X

X

X

Overload detected

Page 46: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 46

Load Shedding

X

X

X

Least valuable task

u = 3

u = 1

u = 5

u = 7

Two scheduling parameters: deadline and utility

Page 47: Real-Time Scheduling CS 3204 – Operating Systems Lecture 13 10/3/2006 Shahrooz Feizabadi.

CS3204 Fall 2006 10/3/06 47

Load Shedding

X

Least valuable task

u = 3

u = 1

u = 5

u = 7


Recommended