From 1-level to Multi-level Preemption
4.2 Analysis
4.2.1 A brief background on CPA
4.2 Analysis 75
1 2 3 4 5
00 50 100 150 200
n
ɳ(∆t)
(∆t) ɳ+ (∆t)
ɳ-(∆t)
0 1 2 n 3 4
× δ-(n)
* δ+(n)
×
×
×
×
5
*
*
*
50 100 150 200
(∆t)
(a.) An event arrival function.
1 2 3 4 5
00 50 100 150 200
n
ɳ(∆t)
(∆t) ɳ+ (∆t) ɳ-(∆t)
0 1 2 n 3 4
× δ-(n)
* δ+(n)
×
×
×
×
5
*
*
*
50 100 150 200
(∆t)
(b.) An event distance function Figure 4.2: CPA event model for a task with a period and jitter of 50 time units.
Since the WCRT ofτi may not occur on its first activation, the CPA examines all q activations of τi within the level-i busy period. To this end, it defines an q-activation processing time Bi(q), which describes how long the resourceρis busy processingqjobs ofτi. This is computed in Equation4.1.
Bi(q) =Q+i(q) +Ci+ (4.1)
Note in Equation 4.1 that Bi(q) assumes a non-preemptive scheduling scheme. Here Q+i(q) is the time interval between the start of the level-i busy period and the start of service of theqthinstance ofτi. It is calculated as in Equation4.2.
Q+i(q) = max
j∈l p(i){C+j} + (q−1) ⋅Ci++ ∑
k∈hp(i)
C+k ⋅ηk+(Qi(q) +ε) (4.2) In Equation4.2, l p(i)andhp(i)denote the set of tasks with a lower and higher priority than τi, respectively. The first term computes the maximum delay that can be caused by the presence of a lower-priority task in the system; the second term estimates the delay caused by processing all previousq−1 instances, and the third term computes all possible delays caused by serving higher priority tasks withinBi(q). It is worth noting that Equation4.2is reminiscent of the Worst-Case Response Time estimation for the classical single-core fixed-priority tasks and is also solved using a fixed-point algorithm, i.e., the solution is computed iteratively and the algorithm stops as soon as two consecutive values
ofQ+i(q)are equal or when a value exceeds the deadline. In the latter case, the set of tasks is deemed unschedulable. Having obtainedQ+i(q), we can derive the maximum number of activationsq+i ofτiwithinBi(q)using Equation4.3.
q+i =min{q≥1∣Bi(q) <δi−(q+1)} (4.3) This equation computes the first qi instances of τi such that the completion time of instanceqiis less than the earliest arrival time of instanceqi+1. The response time of the qth instance ofτiis given by the difference between the time when allqinstances ofτiare processed and the arrival time of instanceq. Formally, this is given by Equation4.4.
R+i(q) =Bi(q) −δi−(q) (4.4)
Finally, the WCRTR+i ofτiis the maximumR+i(q)over allq+i activations ofτiwithin the busy window and is calculated by Equation4.5.
R+i = max
1≤q≤q+i {R+i(q)} (4.5)
So far, we have discussed the worst-case delay at each resource node, also referred to aslocal analysis. Specifically, at each resource node, a rigorous computation is performed on the maximum possible blocking/interference that a task can suffer. This means that the potential interference between any two tasks is effectively captured when performing local analysis at the shared resource node. However, in many cases, real-time applications involve interacting tasks that share different resources. To evaluate the WCRT of a task in this scenario, the CPA defines anevent propagationstep in addition to the local analysis step. Here, the output of each resource along the execution path of a task serves as the input to the next, andR+i(q)at the last node is the WCRT of the task.
The CPA approach has been applied to standard Ethernet (Rox and Ernst,2010;Thiele et al.,2015b), AVB (Diemer et al.,2012a), and TSN (Thiele and Ernst,2016b,a). In these works, the output ports of the switches areresourcesand flows aretasks. The frames are jobs orinstancesof the tasks and the path of a flow is modeled as a chain of dependent tasks (Diemer et al.,2012a). Specifically, resources render someservice(s)(transmission) to some task activations (frames) upon the occurrence of an event (arrival of frames) within a time window (a level-ibusy period). In this context, the service period of each frame is bounded by two parameters: from above byC+ and from below byC−. These parameters represent the longest and the shortest time for the frame to transmit in the absence of any interference. They depend, of course, on the minimum and maximum possible payload p−/+ of the flow to which the frame belongs and on the speed of the
4.2 Analysis 77
output link. Equation4.6illustrates the relationship between these parameters1. C−/+=42 bytes+max{42 bytes,p−/+}
rT X (4.6)
In this equation,rT X represents the transmission speed on the port link and the con-stant terms (here, 42) represent the protocol overhead and minimum frame payload re-quirement as specified in the Standards (IEEE,2018a).
Output Queues Input Buffers
74 Input
Delay Queueing
Delay Transmission Delay Processing
Delay Propagation
Delay
Output Queues
Figure 4.3: End-to-end delay components.
As shown in Figure4.3, the end-to-end delay experienced by a frame in a switch fabric is composed of the following five components: (1) the input delay at the switch input port; (2) the processing delay; (3) the queuing delay at the switch output port; (4) the propagation delay; and finally (5) the transmission delay (Finn, 2017). As pointed out byThiele and Ernst(2016a), all of these components are implementation-dependent and are generally on the order of a few clock cycles, with the exception of the queueing delay, which is captured in Equation4.2and whose components are shown in Figure4.4.
In Figure4.4, frame fiq arrives at time aqi during the transmission of a frame of the lower preemption class (green box). Beforeaqi, the express class frame (first red box) and two other frames (first two yellow boxes) with the same priority and preemption class as fiq had arrived. The preemption operation commands that a minimum number of bytes have been transmitted and a number of bytes remain for the preempted fragment to satisfy the minimum size of a valid Ethernet frame. This brings the highest possible blocking that a preempting frame can experience to the size of the largest non-preemptable fragment of a preemptable frame, i.e., 143 bytes of data (Thiele and Ernst,2016a) and explains the transmission process of the lower priority frame before it is preempted. After the lower priority frame is preempted, the express frame, all pending frames of the same priority,
1The minimum size of a frame is 84 bytes according to the specification of the Standard
2 4 6 8 10
0
time(t)
Higher-priority frames Same-priority frames
Frame arrival/release Preemption overhead Lower-priority frames
𝒇𝒊𝒒 𝒂𝒊𝒒
𝑸𝒊(𝒒, 𝒂𝒊𝒒)
Figure 4.4: Queuing delay components.
and all newly arrived express frames are transmitted, thus forcing fiq to be served only afterward.
In addition to the queueing delay components captured in Equation 4.2, preemption overhead is another term that should be considered. This is not the case in the general CPA model (Hofmann et al., 2017). Preemption overhead is an important factor in the TSN frame transmission scheme. The total overhead incurred by each preemption is 12 bytes (i.e., 6-byte preamble, 1-byte start frame delimiter, 1-byte frame count variable;
and finally 4-byte error check variable) (Ojewale et al.,2018). In addition, theInter Frame Gap (IFG) between two consecutive transmissions must be considered before the next frame/fragment is transmitted. According to the standards, the size of each IFG is equal to the time required to transmit 12 bytes of data. Thus, the total overhead associated with each preemption amounts to 24 bytes.Thiele and Ernst(2016a) have also proved that the maximum number of preemptions that a single frame can suffer is given by Equation4.7.
Fi+= ⌊
p+i −42bytes
60bytes ⌋ (4.7)
Equation4.7provides an upper bound on the number of times an Ethernet frame can be preempted based on the minimum valid frame size constraints defined in the stan-dards. In this equation, the constant terms (here 42 and 60) are the minimum payload requirements for the first and subsequent fragments of a preemptable frame in the
stan-4.2 Analysis 79
dards (IEEE,2018a). For each flow fi, its worst-case traversal time is obtained by com-bining the Equations4.1and4.4.
We note that Equation4.4 does not account for preemption overhead. This com-putation is refined to include the cost in Section 4.2.2.6. Note also that the CPA model allows for arbitrary deadlines, i.e., there is no particular correlation between the deadline and the minimum inter-arrival time of each flow.