3.2 Problem formulation
3.2.1 Temporal scheduling constraints
Note that the mth instance of partition i is executed in the time interval Im(ti) = [ti+ mTi, ti+ mTi+ bi) .
To avoid overlap in execution times between two partitions i and j allocated to the same module, any two invocations m and n of these partitions must not overlap in time. This can be expressed as follows:
∀(i, j) ∈ Π2, ∀m, n ∈ IN∗, ∀k ∈ P aik= ajk= 1 ⇒ Im(ti) ∩ In(tj) = ∅.
Korst proposed in [91] (p.65) a necessary and sufficient condition to ensure that two partitions do not overlap in time. This condition is represented in Section 3.2.1.1.
3.2.1.1 Schedulability condition for strictly periodic partitions
The theory behind the sufficient and necessary schedulability condition proposed in [91] is hereafter presented.
3.2. PROBLEM FORMULATION 71
Theorem 1 (Bachet-B´ezout identity) The Bachet-B´ezout identity [84] proves that if a and b are two
non-zero integers (a, b ∈ Z), then there exists integers x and y such that
ax + by = gcd(a, b)
where gcd(a, b) is the Greatest Common Divisor of a and b.
Definition 3.1 The floor function of a decimal value x ∈ IR is defined as 3x4 ∈ ZZ such that,
x − 1 < 3x4 ≤ x.
Definition 3.2 Given two numbers, a (the dividend) and b (the divisor), a modulo b (abbreviated as a
mod b) is the remainder r, on division of a by b. As will be seen later, given that the divisor b will always be positive, the several definitions on the modulo operation [31] (depending on type of division used, such as Euclidean) yield the same results on the remainder, in other words:
a mod b = a − b #a b $
= r (3.2)
with r following the positive sign of b and satisfying 0 ≤ r < |b|.
In the rest of this thesis, the symbol % is used as a shorthand notation for the modulo operator, i.e. a%b is to be read a mod b.
Denote by gi,j the greatest common divisor of Ti and Tj, the periods of partitions i and j respec-
tively (Remark that gi,j = gj,i). Consequently, Ti= nigi,jand Tj = njgi,j.
Using the definition of modulo (3.2):
(tj − ti)%gi,j = (tj − ti) − qj,igi,j,
where tiand tjare the start times for partitions i and j respectively. The quotient in the division between
(tj− ti) and gi,jis represented by qj,i, that is,
qj,i =
: tj− ti
gi,j
; .
Lemma 2 For any two partitions i and j executing on the same module,
min
k,l∈ZZ|(tj+ lTj) − (ti+ kTi)| = min [ (tj− ti)%gi,j , (ti− tj)%gi,j] (3.3)
where k, l ∈ ZZ represent execution instances for the two partitions.
Proof. Assume that tj+ lTj ≥ ti+ kTi. The distance between the two executions is then
(tj+ lTj) − (ti+ kTi) = (tj − ti)%gi,j+ qj,igi,j+ lTj− kTi
72 3. MILP FORMULATION OF THE SCHEDULING PROBLEM
Since 0 ≤ (tj− ti)%gi,j < gi,j, the condition tj+ lTj ≥ ti+ kTiimplies that qj,i+ lnj− kni ≥ 0
and thus that
(tj+ lTj) − (ti+ kTi) ≥ (tj− ti)%gi,j. (3.4)
According to Theorem 1, there exist k, l ∈ ZZ such that qj,igi,j = kTi − lTj and thus the above
inequality can be satisfied as an equality. The proof in the case tj+ lTj < ti+ kTiis symmetric.
In fact, Lemma 2 indicates that the minimal distance between the executions of partitions i and j is min[(tj − ti)%gi,j, (ti− tj)%gi,j]. The term (tj − ti)%gi,j represents the time duration partition i is
allowed to execute without interfering with partition j’s execution. Similarly, (ti− tj)%gi,jrepresents
the execution time partition j is allowed to occupy without interfering with partition i’s execution. This is showed in Figure 3.3 for a two partition example (i and j) with Tj = 2 Ti.
Figure 3.3: Representation of the distance between two partitions.
Theorem 3 For two partitions i and j, the intersection between intervals [ti+ kTi, ti+ kTi+ bi) and
[tj + lTj, tj + lTj+ bj) is empty, ∀(k, l) ∈ Z2, or in other words the two partition executions never
overlap in time on the same module, if and only if
bi ≤ (tj − ti)%gi,j ≤ gi,j− bj. (3.5)
That is, bi ≤ (tj − ti)%gi,jand bj ≤ (ti− tj)%gi,j.
Proof. Let k, l ∈ ZZ such that tj + lTj ≥ ti+ kTi. From (3.4), it can be concluded that a necessary
and sufficient condition for Ik(ti) ∩ Il(tj) = ∅, ∀k, l is (tj − ti)%gi,j ≥ bi.
Similarly, if tj+ lTj ≤ ti+ kTi, a necessary and sufficient condition for Iki(ti) ∩ Ilj(tj) = ∅, ∀k, l
is (ti− tj)%gi,j ≥ bj > 0. This condition can be transformed to (tj− ti)%gi,j ≤ gi,j − bj using the
following,
3.2. PROBLEM FORMULATION 73
Condition (3.5) is obtained and the proof is concluded.
Corollary 4 Ordering between i and j has no effect in equation (3.5). Hence,
bi ≤ (tj− ti)%gi,j ≤ gi,j − bj ⇔ bj ≤ (ti− tj)%gi,j ≤ gi,j− bi
Proof. Again following (3.6),
bi≤ (tj− ti)%gi,j ≤ gi,j − bj ⇔ bi ≤ (−(ti− tj))%gi,j ≤ gi,j− bj
⇔ bi ≤ gi,j− (ti− tj)%gi,j ≤ gi,j− bj
⇔ bj ≤ (ti− tj)%gi,j ≤ gi,j− bi.
Theorem 3 assists in validating a schedule, i.e. there is no overlapping in execution times between partitions on modules, if and only if each couple of partitions (on a module) verify condition (3.5). This condition between partitions i and j can be equivalently written as the following linear constraints:
∀(i, j) ∈ Π2, ∀k ∈ P,
bi− (2 − ai,k− aj,k) Z ≤ (tj− ti) − qj,igi,j ≤ gi,j− bj+ (2 − ai,k− aj,k) Z, (3.7)
where qj,iis as indicated earlier the integer variable representing the quotient from the modulo opera-
tion in (3.5) (i.e. qj,i =
#t
j−ti
gi,j
$
) and Z is a large constant that ensures that the constraint is not active unless ai,k = aj,k = 1. That is to say that the schedulability constraint is not important unless the
two partitions execute on the same module. The introduction of Z to obtain conditional constraints was inspired from [130].
To properly linearise the problem, the quotient qj,i must verify the following constraint for every
partition couple allocated the same module,
0 < (tj− ti) − qj,igi,j < gi,j. (3.8)
Clearly, given that bi and bj are positive, verifying constraints (3.7) imply the validity of (3.8).
Hence, (3.8) represent redundant constraints. From Definition 3.1 tj− ti gi,j − 1 <: tj− ti gi,j ; ≤ tj− ti gi,j , and hence a bound for qj,ican be supplied, which is:
−Ti+ bi gi,j − 1 < qj,i≤ Tj− bj gi,j . (3.9)
Additionally, as indicated in Section 3.1.2 (ti ∈ Ti), a schedule t must satisfy the following:
0 ≤ ti< Ti, ∀i ∈ Π. (3.10)
In the following, let ζ(a, b) denote the set of all feasible schedules t satisfying (3.7) and (3.10), where b = (bi) is the vector representing partition time budgets, and a is the vector representing
74 3. MILP FORMULATION OF THE SCHEDULING PROBLEM