11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

28
1 G53SRP: Feasibility analysis Chris Greenhalgh Chris Greenhalgh School of Computer School of Computer Science Science

description

3 Introduction Feasibility = whether a set of processes, if scheduled correctly, will meet their deadlines – –RTSJ: all active RealtimeThread s and AsyncEventHandler s (i.e. Schedulable s) Also known as “Schedulability” Can be determined analytically given enough information about the system…

Transcript of 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

Page 1: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

11

G53SRP: Feasibility analysis

Chris GreenhalghChris GreenhalghSchool of Computer ScienceSchool of Computer Science

Page 2: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

22

Contents• IntroductionIntroduction• Process and scheduling model• Utilisation tests• Response time analysis• Run-time feasibility testing in RTSJ• SummarySummary

• Book: Wellings Ch. 10 (part), Burns & Wellings Book: Wellings Ch. 10 (part), Burns & Wellings 12.5-12.6; 13.1-13.5, 13.7, 13.9, 13.10 (part)

Page 3: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

3

Introduction• Feasibility

= whether a set of processes, if scheduled correctly, will meet their deadlines

– RTSJ: all active RealtimeThreads and AsyncEventHandlers (i.e. Schedulables)

• Also known as “Schedulability”• Can be determined analytically given

enough information about the system…

Page 4: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

4

(Simple) Process and scheduling model

• Fixed set of processes• Known worst-case execution times• Independent processes

– See later notes for some information on dealing with competition between threads

• Periodic; known deadlines• Zero time context switch• Correctness = meet deadlines• Priority-based scheduling

– Pre-emptive– No timeslicing

Page 5: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

5

Process parameters:• D = deadline (time period)

– RTSJ: ReleaseParameters deadline• T = period of periodic process

– RTSJ: PeriodicParameters period– Sporadic process minimum interarrival time– RTSJ: SporadicParameters minimumInterarrival

– Feasibility analysis not possible for aperiodic processes, i.e. no process set with an aperiodic process is feasible

• C = worst case execution time– RTSJ: ReleaseParameters cost

Page 6: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

6

Scheduling approach• Fixed Priority Scheduling (FPS)

– RTSJ: PriorityScheduler– Single fixed priority allocated in advance for each

process– Runnable processes executed in order of priority

• Deadline Monotonic Priority Order (DMPO)– Allocate highest priority to shortest deadline– Provably optimal for FPS– RTSJ: Priorities specified by programmer via SchedulerParameters (PriorityParameters)

Page 7: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

7

Schedulability (1): Utilisation tests

• Is there enough CPU capacity?– Sum(Ci/Ti) <= 1

• But:– Necessary (not sufficient)– D=T only

Fraction of CPUused by process

Total CPU(no. of CPUs)

Page 8: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

8

For example:• Process set

– Proc. T C– 1 5

2– 2 4

2• Utilization = 2/5+2/4

= 0.85– Might be schedulable

:-/

• Process set– Proc. T C– 1 5

3– 2 4

2• Utilization = 3/5+2/4

= 1.10– Definitely not

schedulable

Page 9: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

9

Example time-line (first case)

2/2 2/2

0 1 2 3 4 5 6

Time

Process

1

2

2/2

Process Release Time

Process Completion TimeDeadline MetProcess Completion TimeDeadline Missed

Executing

Preempted

(consider P1 cost=2.01=> U = 0.852!)

Page 10: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

10

Example time-line (second case)

2/2 2/2

0 1 2 3 4 5 6

Time

Process

1

2

2/3

Process Release Time

Process Completion TimeDeadline MetProcess Completion TimeDeadline Missed

Executing

Preempted

Page 11: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

11

Schedulability (2): Utilisation bound test (Liu & Leyland)

• Is there enough CPU capacity?– Sum(Ci/Ti) <= N(2(1/N)-1)

• But:– Sufficient (not necessary)– D=T only– 1 CPU

N N(2(1/N)-1)

1 1.0

2 0.828

3 0.780

4 0.757

10 0.718

0.69

Jolly clever formula worked out by Liu & Leylard (see Burns & Wellings)

Page 12: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

12

For example:• Process set

– Proc. T C– 1 5 2– 2 4 1

• Utilization = 2/5+1/4 = 0.65– Bound 2 processes = 0.828– Schedulable!

Page 13: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

13

Example time-line

1/1 1/1

0 1 2 3 4 5 6

Time

Process

1

2

2/2

Process Release Time

Process Completion TimeDeadline MetProcess Completion TimeDeadline Missed

Executing

Preempted

Page 14: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

14

Process Period ComputationTime Priority Utilization T C P U

a 50 12 1 0.24 b 40 10 2 0.25 c 30 10 3 0.33

Another example Process Set

• The combined utilization is 0.82 (or 82%)• This is above the threshold for three processes

(0.78) and, hence, this process set fails the utilization test

Page 15: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

15

Example time-line

10 2

10

10 10

0 10 20 30 40 50 60

Time

Process

a

b

c

10

Process Release Time

Process Completion TimeDeadline MetProcess Completion TimeDeadline Missed

Executing

Preempted

Page 16: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

16

Example Gantt Chart

c b a c b

0 10 20 30 40 50

Time

Page 17: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

17

Schedulability (3): Response time analysis

• Consider a worst-case scenario:– Every process is released at the same moment– Will they all meet their deadlines?– i.e. is the worst-case response time (completion

time) for each process <= its deadline?

Page 18: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

18

Release of process (nominal start time)

Time

Deadline

a

b

Interference from higher priority

processes, Iii

Units of execution

End of process execution

-> response time, Rii=Cii+Iii

c

execution time Cii = a + b +c

With preemptivefixed priority scheduling the onlyreason we aren’t actually running(given assumptions)

Page 19: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

19

Response time analysis (1)• Necessary and sufficient

– D <= T• (i) Ri = Ci+Ii

– Ri = response time– Ci = worst case execution time– Ii = interference

• (ii) Ri = Ci+SUMj (ceil(Ri/Tj)*Cj)– where j : Pj>Pi

– ceil(Ri/Tj) = max. number of times that process j released in time during i

Page 20: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

20

Response time analysis (2)• Solve by:

– wi(0) = Ci

– wi(n+1) = Ci +SUM j (ceil(wi

(n)/Tj ) *Cj)• where j : Pj >Pi

• From highest priority to lowest– until converges

• Schedulable iff– Ri <= Di

Page 21: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

21

For example:• Process set

– Proc. T C D P– 1 5 2 3 1– 2 4 1 2 2

• Process 2:– w2

(0) = C2 = 1

– R2 = w2(0) = 1

Page 22: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

22

R2 < D2 !• Process 1:

– w1(0) = C1 = 2

– w1(1) = C1+ceil(w1

(0)/T2)*C2 = 3

– w1(2) = C1+ceil(w1

(1)/T2)*C2 = 3

– R1 = w1(2) = 3

– R1 < D1 !

• Schedulable!

Page 23: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

23

Past paper questions• 2004 Q2, 2003 Q2, 2002 Q3, 2001 Q4,

2000 Q2.

Page 24: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

24

Run-time feasibility testing in RTSJ

• RTSJ Scheduler may implement run-time feasibility checking– Default PriorityScheduler just assumes any

process set without aperiodic processes is feasible• Scheduler manages a “feasibility set” of Schedulables – i.e. RealtimeThreads and AsyncEventHandlers

– To which any schedulability analysis is applied• Scheduler abstract class and Schedulable

interface include various methods for checking feasibility and conditionally changing parameters…

Page 25: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

25

Scheduler class (part)package javax.realtime;public abstract class Scheduler {` … protected boolean addToFeasibility(Schedulable s); protected boolean removeFromFeasibility(Schedulable s); public boolean isFeasible(); public boolean setIfFeasible(Schedulable s, ReleaseParameter r, MemoryParameters m, ProcessingGroupParameters g); …}

Now feasible?

Page 26: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

26

Schedulable class (part)package javax.realtime;public interface Schedulable extends Runnable { … public boolean addIfFeasible(); public boolean addToFeasibility(); public boolean removeFromFeasibility(); public boolean setIfFeasible( SchedulableParameters s, ReleaseParameter r, MemoryParameters m, ProcessingGroupParameters g); public boolean setSchedulingParametersIfFeasible( SchedulableParameters s); …}

Page 27: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

27

Summary (1)• Feasibility = schedulability, i.e. whether a

set of processes should meet its deadlines• Typically requires simplifying assumptions

– E.g. zero time context switch• Simple tests based on CPU utilisation

– Total CPU requirements– Liu & Leyland’s utilisation bound – => necessary or sufficient but not both

Page 28: 11 G53SRP: Feasibility analysis Chris Greenhalgh School of Computer Science.

28

Summary (2)• Response time analysis

– Models worst case simultaneous release of all processes– Simple case models pre-emption by higher priority

processes only– Can be extended to consider process conflict (e.g.

resource sharing)• RTSJ provides an API for run-time feasibility RTSJ provides an API for run-time feasibility

testingtesting– In In Scheduler Scheduler & & SchedulableSchedulable – SchedulerScheduler maintains feasibility set maintains feasibility set – ““Process” = Process” = SchedulableSchedulable, i.e. , i.e. RealtimeThreadRealtimeThread

or or AsyncEventHandlerAsyncEventHandler