In this section, we present schedulability tests for fixed-priority scheduling using response time analysis and for EDF scheduling using processor demand analysis. Both analyses are sustainable (Baruah and Burns 2006) in the sense that any taskset that was deemed schedulable by the test remains schedulable if the parameters “improve”, e.g., if the execution times decrease or periods increase.
Fixed priority pre-emptive scheduling
We now recapitulate the exact (sufficient and necessary) schedulability test for fixed priority pre-emptive scheduling of constrained-deadline tasksets based on response time analysis (Audsley et al. 1993; Joseph and Pandya 1986; Davis et al. 2008). Subsequent work on integrating cache related pre-emption delays into schedulability analysis for fixed priority pre-emptive systems is based on this analysis. The basic form given below assumes that pre-emption costs are zero.
We assume that the index i of task \(\tau _i\) represents its priority, hence \(\tau _1\) has the highest priority, and \(\tau _n\) the lowest. We use the notation hp(i) (and lp(i)) to mean the set of tasks with priorities higher than (and lower than) i, and the notation hep(i) (and lep(i)) to mean the set of tasks with priorities higher than or equal to (lower than or equal to) i.
The worst-case response time \(R_i\) of a task \(\tau _i\) is given by the longest possible time from release of a job of the task until it completes execution. Thus task \(\tau _i\) is schedulable if and only if \(R_i \le D_i\) , and a taskset is schedulable if and only if all of its tasks are schedulable.
The response time \(R_i\) of a task necessarily contains its execution time \(C_i\), and in addition, \(\tau _i\) may suffer interference and be pre-empted by tasks with higher priority than i. Let \(\tau _j\) be such a task. Within the response time \(R_i\) of \(\tau _i\), task \(\tau _j\) executes at most \(\left\lceil \frac{R_i}{T_j}\right\rceil \) times, each time for at most \(C_j\). Hence, the response time \(R_i\) of task \(\tau _i\) is given by:
$$\begin{aligned} R_i = C_i + \sum _{\forall j \in \mathrm{hp}(i)} \left\lceil \frac{R_i}{T_j} \right\rceil C_j \end{aligned}$$
(2)
where \({\mathrm{hp}}(i)\) denotes the set of tasks with higher priority than i. The response time \(R_i\) of task \(\tau _i\) appears on both the left-hand side and the right-hand side of (2). As the right-hand side is a monotonically non-decreasing function of \(R_i\), then a solution may be found via fixed-point iteration:
$$\begin{aligned}&R_i^{x+1} = C_i + \sum _{\forall j \in \mathrm{hp}(i)} \left\lceil \frac{R_i^x}{T_j} \right\rceil C_j \end{aligned}$$
(3)
Iteration starts with an initial value, typically \(R_i^0 = C_i\), and ends when either \(R_i^{x+1} > D_i\) in which case the task is unschedulable, or when \(R_i^{x+1} = R_i^x\), in which case the task is schedulable, with a worst-case response time \(R_i^{x+1}\). We note that convergence may be speeded up using the techniques described by Davis et al. (2008).
Pre-emption cost aware schedulability test
To integrate pre-emption costs into response time analysis, Busquets-Mataix et al. (1996) extended (2) by adding a term \(\gamma _{i,j}\) representing the pre-emption cost of a job of task \(\tau _j\) executing during the response time of task \(\tau _i\) (with \(j \in hp(i)\)):
$$\begin{aligned} R_i = C_i + \sum _{\forall j \in \mathrm{hp}(i)} \left\lceil \frac{R_i}{T_j} \right\rceil (C_j + \gamma _{i,j}) \end{aligned}$$
(4)
An alternative approach was taken by Petters and Farber (2001) and later Staschulat et al. (2005), who based their analyses on the following equation:
$$\begin{aligned} R_i = C_i + \sum _{\forall j \in \mathrm{hp}(i)} \left( \left\lceil \frac{R_i}{T_j} \right\rceil C_j + \hat{\gamma }_{i,j} \right) \end{aligned}$$
(5)
The value \(\hat{\gamma }_{i,j}\) denotes the pre-emption cost of all jobs of task \(\tau _j\) executing during the response time of task \(\tau _i\) (again with \(j \in hp(i)\)). It is given by the \(\left\lceil \frac{R_i}{T_j} \right\rceil \)-highest pre-emption costs of a job of task \(\tau _j\) executing during \(R_i\). Although the difference with respect to (4) is subtle, more precise analysis can be obtained by using \(\hat{\gamma }_{i,j}\) as a bound on the overall impact of all jobs of \(\tau _j\) on the response time \(R_i\) instead of a bound on the impact of just one job of \(\tau _j\).
We note that when pre-emption costs are considered explicitly, the worst-case scenario is not necessarily given by a synchronous release of all higher priority tasks (Meumeu Yomsi and Sorel 2007) and hence (4) and (5) provide sufficient, but not exact schedulability tests.
Pre-emption cost computation
The value \(\gamma _{i,j}\) can be computed in a number of different ways, which are described in detail by Altmeyer et al. (2012), here, we restrict our explanations to the two dominant approaches: ECB-Union and UCB-Union.
UCB-Union Tan and Mooney (2007) analysed the pre-emption cost via an upper bound on the number of useful cache blocks (of all pre-empted tasks) that a pre-empting task \(\tau _j\) may evict. As it is only the eviction of useful cache blocks belonging to tasks with equal or higher priority than task \(\tau _i\) that may increase the response time of task \(\tau _i\), only tasks with intermediate priorities in the set \({\hbox {aff}}(i,j) = {\hbox {hep}}(i) \cap lp(j)\), need be considered.
$$\begin{aligned} \gamma _{i,j}^{\mathrm{UCB-U}}= {\hbox {BRT}}\cdot \left| \left( \bigcup _{k \in {\hbox {aff}}(i,j)} {\hbox {UCB}}_k \right) \cap {\hbox {ECB}}_j \right| \end{aligned}$$
(6)
Here, \(\gamma _{i,j}^{\mathrm{UCB-U}}\) represents the worst-case impact a job of task \(\tau _j\) can have on all (useful cache blocks of) tasks with lower priority than task \(\tau _j\) down to task \(\tau _i\). We refer to this approach as UCB-Union.
ECB-Union Instead of considering the precise set of ECBs of a pre-empting task and bounding all possibly affected UCBs (as UCB-Union does), ECB-Union (Altmeyer et al. 2011, 2012) considers the precise number of UCBs of the pre-empted task. It then assumes that the pre-empting task \(\tau _j\) has itself already been pre-empted by all tasks with higher priority. This nested pre-emption of the pre-empting task is represented by the union of the ECBs of all tasks with higher or equal priority than task \(\tau _j\):
$$\begin{aligned} \gamma _{i,j}^{\mathrm{ECB-U}}= \max _{\forall k \in {\hbox {aff}}(i,j)}\left\{ \left| {\hbox {UCB}}_k \cap \left( \bigcup _{h \in \mathrm{hep}(j)} {\hbox {ECB}}_h \right) \right| \right\} \end{aligned}$$
(7)
The UCB-Union and ECB-Union approaches are incomparable in that there are tasks that may be deemed schedulable using one approach but not the other and vice-versa.
Multiset approaches The UCB-Union and ECB-Union can be lifted to the so-called Multiset approaches to be used within Eq. (5) to account for the \(\left\lceil \frac{R_i}{T_j} \right\rceil \)-highest pre-emption costs of a job of task \(\tau _j\) executing during \(R_i\) instead of accounting for the highest pre-emption costs of a job \(\left\lceil \frac{R_i}{T_j} \right\rceil \) times. To simplify our equations, we introduce \(E_k(R_i)\) to denote the maximum number of jobs of task \(\tau _k\) that can execute during response time \(R_i\), i.e.:
$$\begin{aligned} E_k(R_i) = \left\lceil \frac{R_i}{T_k} \right\rceil \end{aligned}$$
The pre-emption cost \(\gamma _{i,j}^{{\mathrm{ECB-M}}}\) is then computed as follows, recognising the fact that task \(\tau _j\) can pre-empt each intermediate task \(\tau _k\) at most \(E_j(R_k)E_k(R_i)\) times during the response time of task \(\tau _i\). We form a multiset M that contains the cost
$$\begin{aligned} \left| {\hbox {UCB}}_k \cap \left( \bigcup _{h \in \mathrm{hp}(j)\cup \{j\}} {\hbox {ECB}}_h \right) \right| \end{aligned}$$
(8)
of \(\tau _j\) pre-empting task \(\tau _k\)
\(E_j(R_k)E_k(R_i)\) times, for each task \(\tau _k \in {\hbox {aff}}(i,j)\). Hence:
$$\begin{aligned} M = \bigcup _{k \in {\hbox {aff}}(i,j)} \left( \bigcup _{E_j(R_k)E_k(R_i)} \left| {\hbox {UCB}}_k \cap \left( \bigcup _{h \in \mathrm{hp}(j)\cup \{j\}} {\hbox {ECB}}_h \right) \right| \right) \end{aligned}$$
(9)
\(\gamma _{i,j}^{{\mathrm{ECB-M}}}\) is then given by the \(E_j(R_i)\) largest values in M.
$$\begin{aligned} \gamma ^{\mathrm{ECB-M}}_{i,j} = {\hbox {BRT}}\cdot \sum _{l=1}^{E_j(R_i)} \vert M^l \vert \end{aligned}$$
(10)
where \(M^l\) is the l-th largest value in M. We note that by construction, the ECB-Union Multiset approach dominates the ECB-Union approach.
The pre-emption cost \(\gamma _{i,j}^{{\mathrm{UCB-M}}}\) is computed as follows, recognising the fact that task \(\tau _j\) can pre-empt each intermediate task \(\tau _k\) directly or indirectly at most \(E_j(R_k)E_k(R_i)\) times during the response time of task \(\tau _i\). First, we form a multi-set \(M_{i, j}^{{\mathrm{ucb}}}\) containing \(E_j(R_k)E_k(R_i)\) copies of the \({\hbox {UCB}}_k\) of each task \(k \in {\hbox {aff}}(i,j)\). This multi-set reflects the fact that during the response time \(R_i\) of task \(\tau _i\), task \(\tau _j\) cannot evict a UCB of task \(\tau _k\) more than \(E_j(R_k)E_k(R_i)\) times. Hence:
$$\begin{aligned} M^{{\mathrm{ucb}}}_{i,j} = \bigcup _{k \in {\hbox {aff}}(i,j)} \left( \bigcup _{E_j(R_k)E_k(R_i)} {\hbox {UCB}}_k \right) \end{aligned}$$
(11)
Next, we form a multi-set \(M^{{\mathrm{ecb}}}_j\) containing \(E_j(R_i)\) copies of the \({\hbox {ECB}}_j\) of task \(\tau _j\) . This multi-set reflects the fact that during the response time \(R_i\) of task \(\tau _i\), task \(\tau _j\) can evict ECBs in the set \({\hbox {ECB}}_j\) at most \(E_j (R_i)\) times.
$$\begin{aligned} M^{{\mathrm{ecb}}}_j = \bigcup _{E_j(R_i)}({\hbox {ECB}}_j) \end{aligned}$$
(12)
\(\gamma _{i,j}^{{\mathrm{UCB-M}}}\) is then given by the size of the multi-set intersection of \(M^{{\mathrm{ecb}}}_j\) and \(M^{{\mathrm{ucb}}}_{i,j}\)
$$\begin{aligned} \gamma _{i,j}^{{\mathrm{UCB-M}}} = {\hbox {BRT}}\cdot \left| M^{{\mathrm{ucb}}}_{i,j} \cap M^{{\mathrm{ecb}}}_j \right| \end{aligned}$$
(13)
We note that by construction, the UCB-Union Multiset approach dominates the UCB-Union approach.
The UCB-Union Multiset and the ECB-Union Multiset approach are incomparable in that there are tasks that may be deemed schedulable using one approach but not the other and vice-versa. More precise analysis can therefore be achieved by using a combination of both approaches as follows:
$$\begin{aligned} R_i = \min \left( R_i^{{\mathrm{ECB-M}}}, R_i^{{\mathrm{UCB-M}}}\right) \end{aligned}$$
(14)
A detailed description of the pre-emption cost aware schedulability tests can be found in Altmeyer et al. (2012).
EDF scheduling
We now recapitulate the exact (sufficient and necessary) schedulability test for pre-emptive EDF scheduling of sporadic tasksets based on processor demand analysis (Baruah et al. 1990). Subsequent work on integrating cache related pre-emption delays into schedulability analysis for EDF scheduled systems is based on this analysis. The basic form given below assumes that pre-emption costs are zero. Pre-emptive EDF scheduling is optimal among all scheduling algorithms on a uniprocessor (Dertouzos 1974) under the assumption of negligible pre-emption overhead.
A necessary and sufficient schedulability test for EDF and implicit deadlines \((D_i = T_i)\) is given by the processor utilizations (Liu and Layland 1973): a task set is schedulable, iff
$$\begin{aligned} U = \sum _i \frac{C_i}{T_i} \le 1 \end{aligned}$$
(15)
This test is necessary, but not sufficient if \(D_i \ne T_i\).
Baruah et al. (1990) introduced the processor demand function h(t), which denotes the maximum execution time requirement of all tasks jobs which have both their arrival times and their deadlines in a contiguous interval of length t. Using this they showed that a taskset is schedulable iff \(\forall t > 0, h(t) \le t\) where h(t) is defined as:
$$\begin{aligned} h(t) = \sum _{i=1} \max \left\{ 0,1+ \left\lfloor \frac{t-D_i}{T_i} \right\rfloor \right\} C_i \end{aligned}$$
(16)
As h(t) can only change when t is equal to an absolute deadline, we can restrict the number of values of t that need to be checked. To place an upper bound on t, and so on the number of calculations of h(t), the minimum interval in which it can be guaranteed that an unschedulable taskset will be shown to be unschedulable must be found. For a general taskset with arbitrary deadlines t can be bounded by \(L_a\) (George et al. 1996):
$$\begin{aligned} L_a = \max \left\{ D_i, \ldots , D_n, \frac{\sum _{i+1}^n (T_i = D_i) U_i}{1-U} \right\} \end{aligned}$$
(17)
And an alternative bound, \(L_b\) given by the length of the synchronous busy period can be used (Ripoll et al. 1996), where \(L_b\) is computed using the following equation using fixed point iteration:
$$\begin{aligned} w^{\alpha + 1} = \sum _{i=1}^n \left\lceil \frac{w^\alpha }{T_i} \right\rceil C_i \end{aligned}$$
(18)
There is no direct relationship between \(L_a\) and \(L_b\), which enables t to be bounded by \(L = \min (L_a, L_b)\). Combined with the knowledge that h(t) can only change at an absolute deadline, a taskset is therefore schedulable under EDF iff \(U \le 1\) and:
$$\begin{aligned} \forall t \in Q, h(t) \le t \end{aligned}$$
(19)
Where Q is defined as
$$\begin{aligned} Q = \{ d_k \vert d_k = kT_i + D_i \wedge d_k < \min (L_a, L_b), k\in \mathbb {N} \} \end{aligned}$$
(20)
Zhang andBurns (2009) presented the Quick convergence Processor-demand Analysis (QPA) algorithm which exploits the monotonicity of h(t) to reduce the number of required checks.
Pre-emption cost aware schedulability test
In order to account for CRPD using EDF scheduling, Lunniss et al. (2013) include a component \(\gamma _{t,j}\) which represents the CRPD associated with a pre-emption by a single job of task \(\tau _j\) on jobs of other tasks that are both released and have their deadlines in an interval of length t. Note, unlike its counterpart in CRPD analysis for fixed priority scheduling, \(\gamma _{t,j}\) refers to the pre-empting task \(\tau _j\) and t, rather than the pre-empting and pre-empted tasks. Including \(\gamma _{t,j}\) in (16) a revised equation for h(t) is obtained:
$$\begin{aligned} h(t) = \sum _{i=1} \max \left\{ 0,1+ \left\lfloor \frac{t-D_i}{T_i} \right\rfloor \right\} (C_i + \gamma _{t,j}) \end{aligned}$$
(21)
The set of affected tasks for EDF is based on the relative deadlines of the tasks:
$$\begin{aligned} {\hbox {aff}}(t_j) = \{ \forall \tau _i \vert t \ge D_i > D_j\} \end{aligned}$$
(22)
Task \(\tau _j\) can only pre-empt tasks with a larger relative deadline than \(D_j\) and only tasks with a relative deadline \(D_i\) less than or equal to t need to be accounted for when calculating h(t)
Pre-emption cost computation
The UCB-Union (see Eq. (23)) and ECB-Union (see Eq. (24)) approaches as used for fixed-priorities can be adapted as follows:
$$\begin{aligned} \gamma _{t,j}^{\mathrm{UCB-U}}= {\hbox {BRT}}\cdot \left| \left( \bigcup _{k \in {\hbox {aff}}(t,j)} {\hbox {UCB}}_k \right) \cap {\hbox {ECB}}_j \right| \end{aligned}$$
(23)
and
$$\begin{aligned} \gamma _{t,j}^{\mathrm{ECB-U}}= \max _{\forall k \in {\hbox {aff}}(t,j)}\left\{ \left| {\hbox {UCB}}_k \cap \left( \bigcup _{h \in \mathrm{hep}(j)} {\hbox {ECB}}_h \right) \right| \right\} \end{aligned}$$
(24)
The UCB-Union and ECB-Union approaches are incomparable in that there are tasks that may be deemed schedulable using one approach but not the other and vice-versa.
Similar to Eq. (5) that accounts for the highest n pre-emption costs of a job instead of the highest pre-emption costs of a job n times, we can adapt Eq. (21) as follows
$$\begin{aligned} h(t) = \sum _{i=1} \left( \max \left\{ 0,1+ \left\lfloor \frac{t-D_i}{T_i} \right\rfloor \right\} C_i + \gamma _{t,j} \right) \end{aligned}$$
(25)
and lift the UCB-Union and ECB-Union approaches to their multiset counterparts.
The ECB-Union multiset approach computes the union of all ECBs that may affect a pre-empted task during a pre-emption by task \(\tau _j\). It accounts for nested pre-emptions by assuming that task \(\tau _j\) has already been pre-empted by all other tasks that may pre-empt it. The first step is to form a multiset \(M_{t,j}\) that contains the cost of task \(\tau _j\) pre-empting task \(\tau _k\) repeated \(P_j(D_k)E_k(t)\) times, for each task \(\tau _k \in {\hbox {aff}}(t, j)\), where \(P_j(D_k)\) denotes the maximum number of jobs of task \(\tau _j\) that can pre-empt a single job of task \(\tau _k\):
$$\begin{aligned} P_j(D_k) = \max \left( 0,\left\lceil \frac{D_k - D_j}{T_j}\right\rceil \right) \end{aligned}$$
and \(E_k(t)\) is defined as
$$\begin{aligned} E_k(t) = \max \left( 0,\left\lfloor \frac{t-D_k}{T_k} \right\rfloor \right) \end{aligned}$$
Hence:
$$\begin{aligned} M = \bigcup _{k \in {\hbox {aff}}(t,j)} \left( \bigcup _{P_j(D_k)E_k(t)} \left| {\hbox {UCB}}_k \cap \left( \bigcup _{h \in \mathrm{hp}(j)\cup \{j\}} {\hbox {ECB}}_h \right) \right| \right) \end{aligned}$$
(26)
\(\gamma _{t,j}^{{\mathrm{ECB-M}}}\) is then given by the \(E_j(t)\) largest values in M.
$$\begin{aligned} \gamma ^{\mathrm{ECB-M}}_{t,j} = {\hbox {BRT}}\cdot \sum _{l=1}^{E_j(t)} \vert M^l \vert \end{aligned}$$
(27)
The pre-emption cost \(\gamma _{t,j}^{{\mathrm{UCB-M}}}\) for EDF scheduling is computed similarly to the UCB-Union Multiset approach for fixed-priority scheduling: Task \(\tau _j\) can pre-empt each intermediate task \(\tau _k\) directly or indirectly at most \(P_j(D_k)E_k(t)\) times within the deadline of task \(\tau _i\). First, we form a multi-set \(M_{t, j}^{{\mathrm{ucb}}}\) containing \(P_j(D_k)E_k(t)\) copies of the \({\hbox {UCB}}_k\) of each task \(k \in {\hbox {aff}}(t,j)\) reflecting the fact that within time t, task \(\tau _j\) cannot evict a UCB of task \(\tau _k\) more than \(P_j(D_k)E_k(t)\) times. Hence:
$$\begin{aligned} M^{{\mathrm{ucb}}}_{t,j} = \bigcup _{k \in {\hbox {aff}}(t,j)} \left( \bigcup _{P_j(D_k)E_k(t)} {\hbox {UCB}}_k \right) \end{aligned}$$
(28)
Next, we form a multi-set \(M^{{\mathrm{ecb}}}_j\) containing \(E_j(t)\) copies of the \({\hbox {ECB}}_j\) of task \(\tau _j\). This multi-set reflects the fact that during t, task \(\tau _j\) can evict ECBs in the set \({\hbox {ECB}}_j\) at most \(E_j(t)\) times.
$$\begin{aligned} M^{{\mathrm{ecb}}}_j = \bigcup _{E_j(t)}({\hbox {ECB}}_j) \end{aligned}$$
(29)
\(\gamma _{i,j}^{{\mathrm{UCB-M}}}\) is then given by the size of the multi-set intersection of \(M^{{\mathrm{ecb}}}_j\) and \(M^{{\mathrm{ucb}}}_{i,j}\)
$$\begin{aligned} \gamma _{i,j}^{{\mathrm{UCB-M}}} = {\hbox {BRT}}\cdot \left| M^{{\mathrm{ucb}}}_{i,j} \cap M^{{\mathrm{ecb}}}_j \right| \end{aligned}$$
(30)
We note that the UCB-Union Multiset and the ECB-Union Multiset approach for EDF are also incomparable and hence, a combined approach can be defined as follows:
$$\begin{aligned} h(t) = \min \left( h(t)^{{\mathrm{ECB-M}}}, h(t)^{{\mathrm{UCB-M}}}\right) \end{aligned}$$
(31)
As the multiset approaches effectively inflate the execution time of task \(\tau _j\) by the CRPD that it can cause in an interval of length t, the upper bound L, used for calculating the processor demand h(t), must be adjusted. This is achieved by calculating an upper bound on the utilisation due to CRPD that is valid for all intervals of length greater than some value \(L_c\). This CRPD utilisation value is then used to inflate the taskset utilisation and thus compute an upper bound \(L_d\) on the maximum length of the synchronous busy period. This upper bound is valid provided that it is greater than \(L_c\), otherwise the actual maximum length of the busy period may lie somewhere in the interval \([L_d,L_c]\), hence we can use \(max(L_c,L_d)\) as a bound. We refer the reader to (Lunniss et al. 2013) for a detailed explanation.
Optimal task layout
The precise cache mapping, i.e., the mapping of memory block to cache sets strongly influences the pre-emption costs. Consider for instance the extreme situation where all tasks are aligned to the first cache-set: Each task will definitely evict cache blocks of another task. If tasks’ code is instead aligned sequentially in the cache, the pre-emption costs are very likely to be smaller. Lunniss et al. (2012) showed how to optimize the task layout with respect to the taskset schedulability and the pre-emption costs. The technique used determines the order in which the code for each task is placed sequentially in memory, without leaving any gaps. Optimizing the task layout does not require any changes to the source code or the compilation and is completely transparent to the user. Only the linker file is adapted. The optimzation changes the addresses of the code and data in the binary, but not the code/data itself, hence an appropriate layout can only improve performance.