Skip to content

GEDF scheduler violates EDF policy #426

Open
@edwardalee

Description

@edwardalee

The GEDF scheduler is supposed to execute all reactions with smaller (inferred) deadline regardless of level before executing any reactions with a larger deadline or with no deadline. Unfortunately, it does not do that, as shown by the following example (due to @soyerefsane). For some reason, instead of using a single reaction queue, the GEDF scheduler uses a separate reaction queue for each level (anybody know why?). This means that it will only prioritize a reaction with a deadline over another reaction if both reactions are at the same level.

In the following program, at each tag, detetctor2 should always execute before task1. In the current realization, it never executes before task1.

image
target C {
  timeout: 200ms,
  workers: 1
};

reactor Periodic(period:time = 50ms, name:string = "Unnamed") {
  timer trigger(0, period)
  
  output t: time
  
  reaction(trigger) -> t {=
    instant_t start_time = lf_time_physical_elapsed();
    lf_set(t, start_time);
    lf_print("%s started at physical time: " PRINTF_TIME, self->name, start_time);
  =} 
}

reactor Probe(dl:time = 2ms, name:string = "Unnamed") {
  input i: time
  output t: time
  
  reaction (i) -> t {=
    lf_set(t, lf_time_physical_elapsed());
    lf_print("%s started at physical time: " PRINTF_TIME, self->name, lf_time_physical_elapsed());
  =} deadline (dl) {=
    lf_set(t, lf_time_physical_elapsed());
    lf_print("%s VIOLATED DEADLINE at physical time: " PRINTF_TIME, self->name, lf_time_physical_elapsed());
  =}
}

main reactor {
  task1 = new Periodic(period = 50ms, name = "task1")
  detector1 = new Probe(dl = 50ms, name = "detector1")
  
  task1.t -> detector1.i  
  task2 = new Periodic(period = 50ms, name = "task2")
  detector2 = new Probe(dl = 25ms, name = "detector2")
  
  task2.t -> detector2.i
  
  reaction(task1.t, detector2.t) {=
    if (task1.t->is_present && detector2.t->is_present && task1.t->value < detector2.t->value) {
      lf_print_error_and_exit("EDF policy violated. detector2 should execute before task1 when both are triggered.");
    }
  =}
}

Sample output:

bin/PeriodicTask
---- System clock resolution: 1000 nsec
---- Start execution at time Sun May 12 18:30:03 2024
---- plus 75281000 nanoseconds
Environment 0: ---- Intializing start tag
Environment 0: ---- Spawning 1 workers.
task2 started at physical time: 1219000
task1 started at physical time: 1225000
detector2 started at physical time: 1228000
detector1 started at physical time: 1230000
FATAL ERROR: EDF policy violated. detector2 should execute before task1 when both are triggered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions