aboutsummaryrefslogtreecommitdiffstats
path: root/native/src/edf/load.cpp
blob: db44d20ead4f83b5a4ff542c1a371e29d1fa724a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "tasks.h"
#include "schedulability.h"

#include "edf/load.h"

#include <iostream>
#include <algorithm>

/* This implements the LOAD test presented in:
 *
 *   Baker & Baruah (2009), An analysis of global EDF schedulability for
 *   arbitrary-deadline sporadic task systems, Real-Time Systems, volume 43,
 *   pages 3-24.
 */

bool LoadGedf::is_schedulable(const TaskSet &ts, bool check_preconditions)
{
    if (check_preconditions)
	{
        if (!(ts.has_only_feasible_tasks()
              && ts.is_not_overutilized(m)))
            return false;
    }

    fractional_t load, max_density, mu, bound, cond1, cond2;
    integral_t mu_ceil;

    // get the load of the task set
    ts.approx_load(load, epsilon);

    // compute bound (corollary 2)
    ts.get_max_density(max_density);

    mu = m - (m - 1) * max_density;

    mu_ceil = mu.get_num();
    // divide with ceiling
    mpz_cdiv_q(mu_ceil.get_mpz_t(),
               mu.get_num().get_mpz_t(),
               mu.get_den().get_mpz_t());

    cond1 = mu - (mu_ceil - 1) * max_density;
    cond2 = (mu_ceil - 1) - (mu_ceil - 2) * max_density;

    bound = std::max(cond1, cond2);

    return load <= bound;
}