Real-Time Calculus Prof. Dr. Jian-Jia Chen LS 12, TU Dortmund 09, Dec., 2014 Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 1 / 35
Arbitrary Deadlines The worst-case response time of τ i by only considering the first job of τ i at the critical instant is too optimistic when the relative deadline of τ i is larger than the period. 0 100 200 300 400 500 600 700 0 100 200 300 400 500 600 700 Consider two tasks: τ 1 has period 70 and execution time 26 and τ 2 is with period 100 and execution time 62. τ 2 s seven jobs have the following response times, respectively: 114, 102, 116, 104, 118, 106, 94. Note that the first job s response time is not the longest. Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 2 / 35
Busy Intervals Definition A τ i -level busy interval (t 0, t] of task τ i begins at an instant t 0 when 1 all jobs in τ i released before t have completed, and 2 a job of τ i releases. The interval ends at the first instant t after t0 when all jobs in τ i released since t 0 are complete. τ 2 τ i t0 busy interval t Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 3 / 35
Abstract Models for Real-Time Calculus Processor Input Stream Tasks Concrete Instance Abstract Representation Service Model Load Model Processing Model Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 4 / 35
Abstract Models for Module Performance Analysis Input Stream CPU BUS DSP Concrete Instance RM TDMA Abstract Representation α β CP U β BUS β DSP TDMA GPC GPC GPC α GPC GPC Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 5 / 35
Overview System View Math. View Module Performance Analysis (MPA) Real-Time Calculus (RTC) Min-Plus Calculus, Max-Plus Calculus Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 6 / 35
Backgrounds Real-Time Calculus can be regarded as a worst-case/best-case variant of classical queuing theory. It is a formal method for the analysis of distributed real-time embedded systems. Related Work: Min-Plus Algebra: F. Baccelli, G. Cohen, G. J. Olster, and J. P. Quadrat, Synchronization and Linearity An Algebra for Discrete Event Systems, Wiley, New York, 1992. Network Calculus: J.-Y. Le Boudec and P. Thiran, Network Calculus -A Theory of Deterministic Queuing Systems for the Internet, Lecture Notes in Computer Science, vol. 2050, Springer Verlag, 2001. Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 7 / 35
Plus-Times and Min-Plus Algebras Algebraic structure a set of (finite or infinite) elements S one or more operators defined on the elements of this set Plus-Times Algebra: Two operators + and, denoted by (S, +, ) Min-Plus Algebra Two operators (min) and (plus), denoted by (S {+ }, inf, +) Infimum: The infimum of a subset of some set is the greatest element, not necessarily in the subset, that is less than or equal to all other elements of the subset. For example, inf{[a, b]} = a, inf{(a, b]} = a, where min{[a, b]} = a, min{(a, b]} = undefined. Supremum: The supremum of a subset of some set is the smallest element, not necessarily in the subset, that is more than or equal to all other elements of the subset. For example, sup{[a, b]} = b, sup{[a, b)} = b, where max{[a, b]} = b, max{[a, b)} = undefined. Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 8 / 35
Definition of Arrival Curves and Service Curves For a specific trace: Data streams: R(t) = number of events in [0, t) Resource stream: C(t) = available resource in [0, t) For the worst cases and the best cases in any interval with length : Arrival Curve [α l, α u ]: α l ( ) = α u ( ) = Service Curve [β l, β u ]: β l ( ) = β u ( ) = inf {R( + λ) R(λ)} λ 0, R sup {R( + λ) R(λ)} λ 0, R inf {C( + λ) C(λ)} λ 0, C sup {C( + λ) C(λ)} λ 0, C Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 9 / 35
Abstract Models for Real-Time Calculus Processor C(t) Input Stream R(t) Tasks R (t) Concrete Instance Abstract Representation Service Model Load Model α( ) β( ) Processing Model Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 10 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time workload maximum events in 3 units 0 2 4 6 8 10 12 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time workload maximum events in 3 units minimum events in 3 units 0 2 4 6 8 10 12 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Arrival Curve: An Example Use a sliding window to get the upper bound of the number of events in a specified interval length. 0 2 4 6 8 10 12 14 time workload maximum events in 3 units possible events in 3 units minimum events in 3 units 0 2 4 6 8 10 12 time Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 11 / 35
Service Curve: An Example Resource Availability availability t 2.5 ms t (ms) Service Curves β = [β l, β u ] service β u β l 2.5 ms (ms) Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 12 / 35
Example 1: Periodic with Jitter A common event pattern that is used in literature can be specified by the parameter triple (p, j, d), where p denotes the period, j the jitter, and d the minimum inter-arrival distance of events in the modeled stream. Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 13 / 35
Example 1: Periodic with Jitter Periodic Periodic with Jitter α u ( ) = p α l ( ) = p + j α u ( ) = p j α l ( ) = p Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 14 / 35
Example 1: Periodic with Jitter j α l ( ) = p { + j α u ( ) = min p, } d Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 15 / 35
More Examples on Arrival Curves 10 (a) 10 (b) 8 α u 8 α u # events 6 4 α l # events 6 4 α l 2 2 # events 0 0 10 20 30 10 8 6 4 2 (c) α u α l 0 0 10 20 30 # events 0 0 10 20 30 10 8 6 4 (d) α u 2 α l 0 0 10 20 30 Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 16 / 35
Example 2: TDMA Resource Consider a real-time system consisting of n applications that are executed on a resource with bandwidth B that controls resource access using a TDMA (Time Division Multiple Access) policy. Analogously, we could consider a distributed system with n communicating nodes, that communicate via a shared bus with bandwidth B, with a bus arbitrator that implements a TDMA policy. TDMA policy: In every TDMA cycle of length c, one single resource slot of length s i is assigned to application i. app 1 app 2 app n app 1 app 2 app n app 1 app 2 app n c c c s n s n s n Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 17 / 35
Example 2: TDMA Resource { β u ( ) = B min c { β l ( ) = B max c s i, s i, c c } ( c s i ) } ( c s i ) Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 18 / 35
More Examples on Service Curves Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 19 / 35
On-Site Exercise Consider a stream of events. There are at most three events and at least 2 events arriving within a time interval [k p, (k + 1) p) for k = 0, 1, 2,.... These 2 or 3 events within a period p are defined as follows: At time k p, there is one event. At time k p + 0.3p, there is another event. Between time k p + 0.4p and k p + 0.5p, there may be one event. How do the upper and lower arrival curves look like? Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 20 / 35
Convolutions Plus-times system theory: signals f, impulse response g, convolution in time domain: h(t) = (f g)(t) = t 0 f (t s)g(s)ds, where f, g can be thought as signals and impulse response, respectively. Min-Plus system theory: streams R, variability curves g, convolution in time-interval domain: R (t) (R g)(t) = inf {R(t λ) + g(λ)}. 0 λ t Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 21 / 35
Abstraction Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 22 / 35
Convolution and De-convolution f g is called min-plus convolution (f g)(t) = inf {f (t λ) + g(λ)} 0 λ t f g is called min-plus de-convolution (f g)(t) = sup{f (t + λ) g(λ)} 0 λ f g is called max-plus convolution (f g)(t) = sup {f (t λ) + g(λ)} 0 λ t f g is called max-plus de-convolution (f g)(t) = inf {f (t + λ) g(λ)} 0 λ Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 23 / 35
Arrival and Service Curves Revisit α l (t s) R(t) R(s) α u (t s) s t. β l (t s) C(t) C(s) β u (t s) s t. Therefore, by using the convolution and de-convolution, we know that α u = R R; α l = R R; β u = C C; β l = C C; The proof for α u : α u ( ) = sup {R( + λ) R(λ)} R( + λ) R(λ), λ 0. λ 0 Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 24 / 35
Tight Curves A curve f is sub-additive, if f (a) + f (b) f (a + b) a, b 0. The sub-additive closure f of a curve f is the largest sub-additive curve with f f and is computed as f = min{f, (f f ), (f f f ),...}. If f is interpreted as an arrival curve, then any trace R that is upper bounded by f is also upper bounded by the sub-additive closure f. Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 25 / 35
Tight Curves A curve f is sub-additive, if f (a) + f (b) f (a + b) a, b 0. The sub-additive closure f of a curve f is the largest sub-additive curve with f f and is computed as f = min{f, (f f ), (f f f ),...}. If f is interpreted as an arrival curve, then any trace R that is upper bounded by f is also upper bounded by the sub-additive closure f. A tight upper arrival curve should satisfy the sub-additive property. Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 25 / 35
Greedy Processing Component (GPC) Component is triggered by incoming events. A fully preemptable task is instantiated at every event arrival to process the incoming event. Active tasks are processed in a greedy fashion in FIFO order. Processing is restricted by the availability of resources. Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 26 / 35
Some Relations (only for your reference) The output upper arrival curve of a component satisfies α u (α u β l ) with a simple and pessimistic calculation. The remaining lower service curve of a component satisfies β l ( ) = sup (β l (λ) α u (λ)) 0 λ Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 27 / 35
More Relations (only for your reference) [β l, β u ] α u = [(α u β u ) β l ] β u α l = [(α u β l ) β l ] β l β u = (β u α l ) 0 [α l, α u ] GPC [β l, β u ] [α l, α u ] β l = (β l α u ) 0 Without formal proofs... Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 28 / 35
Graphical Interpretation [β l, β u ] workload [α l, α u ] GPC [α l, α u ] Maximum buffer B [β l, β u ] Maximum response time D 0 2 4 6 8 10 12 time B = sup{r(t) R (t)} sup{α u (λ) β l (λ)} t 0 λ 0 D = sup{inf{τ 0 : R(t) R (t + τ)}} t 0 = sup{inf{τ 0 : α u ( ) β l ( + τ)}} 0 Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 29 / 35
System Composition CPU BUS DSP Concrete Instance RM TDMA How to Interconnect service? Scheduling β CP U β BUS β DSP α GPC GPC GPC α GPC GPC Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 30 / 35
Scheduling and Arbitration Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 31 / 35
Mixed Hierarchical Scheduling Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 32 / 35
Complete System Composition Input Stream CPU BUS DSP Concrete Instance RM TDMA Abstract Representation α β CP U β BUS β DSP TDMA GPC GPC GPC α GPC GPC Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 33 / 35
RTC Toolbox (http://www.mpa.ethz.ch/rtctoolbox) Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 34 / 35
Advantages and Disadvantages of RTC and MPA Advantages More powerful abstraction than classical real-time analysis Resources are first-class citizens of the method Allows composition in terms of (a) tasks, (b) streams, (c) resources, (d) sharing strategies. Disadvantages Needs some effort to understand and implement Extension to new arbitration schemes not always simple Not applicable for schedulers that change the scheduling policies dynamically. Prof. Dr. Jian-Jia Chen (LS 12, TU Dortmund) 35 / 35