## 4 System Model  
We assume a periodic, fixed priority with constrained deadlines to represent real-time embedded systems. A steady-state system is considered, i.e. callbacks are defined at the initialization phase, and the configuration is still static during run-time since we consider safety-critical systems in the context of this work. The response time of a callback is the duration from the release instant to the completion of the job execution. Each callback must have a relative deadline. If the worst-case response time of the callback is shorter than or equal to its relative deadline, we say that the callback is schedulable. In the following, some useful definitions are given, which are used later in this article. Definition 1 (Gcd): The greatest common divisor (GCD) of two positive integers (a, b), denoted by GCD(a,b), is defined as the greatest positive number that is a common factor of both positive integers (a, b). Example: GCD(3,4) = 1. Definition 2 (Lcm): The least common multiple (LCM) of two positive integers (a, b), denoted by LCM(a,b), is defined as the smallest positive integer that is divisible by both a and b. Example: LCM(3,4) = 12. Let us denote by \(\Delta\), a set of m callbacks \(\Delta=\{\tau_{0},\tau_{1},\ldots\tau_{m}\}\). A callback \(\tau_{i}\) is the smallest piece of code that runs in the context of an executor, denoted \(e_{j}\). A callback \(\tau_{i}\) can be formalized as follows:  
\[\tau_{i}(c_{i},p_{i},d_{i},k_{i}) \tag{2}\]  
* \(c_{i}\): The worst-case execution time (WCET). * \(p_{i}\): The callback period. * \(d_{i}\): The deadline for a callback. * \(k_{i}\): A positive integer that defines the order of callback execution within the executor. Let us denote by \(\zeta\) a set of n executors \(\zeta=\{e_{0},e_{1},\ldots,e_{n}\}\). To model an executor, a multi-frame task model [34] is adopted where the execution of an executor \(e_{j}\) consists of a sequence of \(N\) frames characterized as follows:  
\[(E_{j},P_{j},D_{j},T_{j}) \tag{3}\]  
* \(D_{j}\): The executor deadline. * \(P_{j}\): The executor priority. Figure 3: Scheduling semantics in ROS-2 (source: ros.org). * \(T_{j}\): The executor period. * \(\vec{E}_{j}=[C_{j,0},C_{j,1},\ldots,C_{j,s},\ldots,C_{j,N-1}]\): A vector of \(N_{j}\) components. Each component \(C_{j,i}\) represents the execution time of \(e_{j}\) in frame j. The execution time \(C_{j,s}\) of the \(s^{th}\) frame should be less than the executor period \(T_{j}\). The period \(T_{j}\) of an executor \(e_{j}\) that contains m callbacks can be determined as the greatest common divisor (GCD) of the periods: \[T_{j}=\underset{1\leq i\leq m}{GCD}\{p_{i}\}.\] (4)  
The frames of the executor \(e_{j}\) periodically repeat with a major cycle of \(\pi_{j}\) equal to the least common divisor (LCM) of the callback periods:  
\[\pi_{j}=\underset{1\leq i\leq m}{LCM}\{p_{i}\}. \tag{5}\]  
The number of frames \(N_{j}\) can be determined by dividing the major cycle by the executor period as follows: \(N_{j}=\pi_{j}/T_{j}\). Each execution time \(C_{j,s}\) of the \(s^{th}\) frame \((s=0,1,\ldots,N_{j-1})\) is given by the following equation:  
\[C_{j,s}=\sum_{i=1}^{n}h_{i}(s)*c_{i} \tag{6}\]  
where the function \(h_{i}(s)\) indicates that the \(i^{th}\) callback is present or not in the \(s^{th}\) frame as follows:  
\[h_{i}(s)= \begin{cases}1&if\ f_{i}(s)=s\\ 0&if\ f_{i}(s)\
eq s\end{cases}  \tag{7}\]  
with  
\[f_{i}(s)=\bigg{\lfloor}\frac{s}{\gamma_{i}}\bigg{\rfloor}\gamma_{i} \tag{8}\]  
\(f_{i}(s)\) computes a location for callback \(\tau_{i}\) in frame s (\(f_{i}(s)\leq s\)). \(\gamma_{i}=p_{i}/T_{j}\) represents the repetition factor of \(\tau_{i}\) in \(e_{j}\). \(((n\tau_{i}+\delta_{i})\ mod\ N)\) indicates the position of \(\tau_{i}\). Table 2 summarizes the main notation of the system model. Hereafter, an example with the callbacks set \({}^{\prime}\{\tau_{1}(1,10,8,1)\), \(\tau_{2}(1,15,10,2)\), \(\tau_{3}(1,15,12,3)\) and \(\tau_{4}(1,30,19,4)\}\)' is assigned to one executor \(e_{1}\).