g53srp: feasibility analysis
DESCRIPTION
G53SRP: Feasibility analysis. Chris Greenhalgh School of Computer Science. 1. Contents. Introduction Process and scheduling model Utilisation tests Response time analysis Run-time feasibility testing in RTSJ Summary - PowerPoint PPT PresentationTRANSCRIPT
11
G53SRP: Feasibility analysis
Chris GreenhalghChris Greenhalgh
School of Computer ScienceSchool 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)
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…
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
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
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)
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)
8
For example:• Process set
– Proc. T C
– 1 52
– 2 42
• Utilization = 2/5+2/4 = 0.85– Might be schedulable
:-/
• Process set– Proc. T C
– 1 53
– 2 42
• Utilization = 3/5+2/4 = 1.10– Definitely not
schedulable
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 Met
Process Completion TimeDeadline Missed
Executing
Preempted
(consider P1 cost=2.01=> U = 0.852!)
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 Met
Process Completion TimeDeadline Missed
Executing
Preempted
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)
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!
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 Met
Process Completion TimeDeadline Missed
Executing
Preempted
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
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 Met
Process Completion TimeDeadline Missed
Executing
Preempted
16
Example Gantt Chart
c b a c b
0 10 20 30 40 50
Time
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?
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)
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
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
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
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!
23
Past paper questions• 2004 Q2, 2003 Q2, 2002 Q3, 2001 Q4,
2000 Q2.
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…
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?
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); …}
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
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