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 & WellingsBook: Wellings Ch. 10 (part), Burns & Wellings ; , 13.7, 13.9, (part)
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…
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(C i /T i ) <= 1 But: – –Necessary (not sufficient) – –D=T only Fraction of CPU used by process Total CPU (no. of CPUs)
8 For example: Process set – –Proc.TC ––152––152 ––242––242 Utilization = 2/5+2/4 = 0.85 – –Might be schedulable :-/ Process set –Proc.TC –153–153 –242–242 Utilization = 3/5+2/4 = 1.10 –Definitely not schedulable
9 Example time-line (first case) 2/ Time Process 1 2 2/2 Process Release Time Process Completion Time Deadline Met Process Completion Time Deadline Missed Executing Preempted (consider P1 cost=2.01 => U = 0.852!)
10 Example time-line (second case) 2/ Time Process 1 2 2/3 Process Release Time Process Completion Time Deadline Met Process Completion Time Deadline Missed Executing Preempted
11 Schedulability (2): Utilisation bound test (Liu & Leyland) Is there enough CPU capacity? – –Sum(C i /T i ) <= N(2 (1/N) -1) But: – –Sufficient (not necessary) – –D=T only – –1 CPU N N(2 (1/N) -1) 0.69 Jolly clever formula worked out by Liu & Leylard (see Burns & Wellings)
12 For example: Process set – –Proc.TC ––152––152 ––241––241 Utilization = 2/5+1/4 = 0.65 – –Bound 2 processes = – –Schedulable!
13 Example time-line … 1/ Time Process 1 2 2/2 Process Release Time Process Completion Time Deadline Met Process Completion Time Deadline Missed Executing Preempted
14 Process Period ComputationTime Priority Utilization T C P U a b c 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 Time Process a b c 10 Process Release Time Process Completion Time Deadline Met Process Completion Time Deadline Missed Executing Preempted
16 Example Gantt Chart cbacb 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 i Interference from higher priority processes, I i Units of execution End of process execution iii -> response time, R i =C i +I i c i execution time C i = a + b +c With preemptive fixed priority scheduling the only reason we aren’t actually running (given assumptions)
19 Response time analysis (1) Necessary and sufficient – –D <= T (i) R i = C i +I i – –R i = response time – –C i = worst case execution time – –I i = interference (ii) R i = C i +SUM j (ceil(R i /T j )*C j ) – –where j : P j >P i – –ceil(R i /T j ) = max. number of times that process j released in time during i
20 Response time analysis (2) Solve by: – –w i (0) = Ci – –w i (n+1) = C i +SUM j (ceil(w i (n) /T j ) *C j ) where j : P j >P i From highest priority to lowest – –until converges Schedulable iff – –R i <= D i
21 For example: Process set – –Proc.TCDP ––15231––15231 ––24122––24122 Process 2: – –w 2 (0) = C 2 = 1 – –R 2 = w 2 (0) = 1
22 R 2 < D 2 ! Process 1: – –w 1 (0) = C 1 = 2 – –w 1 (1) = C 1 +ceil(w 1 (0) /T 2 )*C 2 = 3 – –w 1 ( 2) = C 1 +ceil(w 1 (1) /T 2 )*C 2 = 3 – –R 1 = w 1 (2) = 3 – –R 1 < D 1 ! 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 Schedulable s – –i.e. RealtimeThread s and AsyncEventHandler s – –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 testingRTSJ provides an API for run-time feasibility testing –In Scheduler & Schedulable –Scheduler maintains feasibility set –“Process” = Schedulable, i.e. RealtimeThread or AsyncEventHandler