Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixed GEDF_NP and removal of deprecated schedulers #282

Merged
merged 6 commits into from
Oct 6, 2023

Conversation

erlingrj
Copy link
Collaborator

@erlingrj erlingrj commented Oct 4, 2023

@erlingrj erlingrj force-pushed the remove-deprecated-scheds branch from fef6408 to b6c4886 Compare October 5, 2023 10:39
@erlingrj erlingrj requested a review from edwardalee October 5, 2023 14:10
@erlingrj
Copy link
Collaborator Author

erlingrj commented Oct 5, 2023

@edwardalee I propose we merge this and try fixing the GEDF_NP scheduler in a different PR

Copy link
Contributor

@edwardalee edwardalee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, we can merge this AFAIC. Let's also merge this PR in lingua-franca to temporarily disable the automatic selection of GEDF_NP because that scheduler incorrectly executes LF programs, as reported in this issue.

@edwardalee
Copy link
Contributor

Wow, if this is really it, that would be amazing. Unfortunately, with lingua-franca master, using this branch, my test case does not compile:

[100%] Linking C executable federate__a
ld: Undefined symbols:
  _lf_sched_done_with_reaction, referenced from:
      __lf_worker_do_work in libcore.a[11](reactor_threaded.c.o)
  _lf_sched_free, referenced from:
      _environment_free in libcore.a[7](environment.c.o)
  _lf_sched_get_ready_reaction, referenced from:
      __lf_worker_do_work in libcore.a[11](reactor_threaded.c.o)
      __lf_worker_do_work in libcore.a[11](reactor_threaded.c.o)
  _lf_sched_init, referenced from:
      __lf_initialize_trigger_objects in federate__a.c.o
      _lf_reactor_c_main in libcore.a[11](reactor_threaded.c.o)
  _lf_scheduler_trigger_reaction, referenced from:
      _enqueue_port_absent_reactions in libcore.a[9](federate.c.o)
      __lf_trigger_reaction in libcore.a[11](reactor_threaded.c.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [federate__a] Error 1
make[1]: *** [CMakeFiles/federate__a.dir/all] Error 2
make: *** [all] Error 2

The test case is this:

/**
 * This program illustrates how relaxing consistency improves availability, as predicted by the CAL
 * Theorem reported in the following paper:
 *
 * Edward A. Lee, Ravi Akella, Soroush Bateni, Shaokai Lin, Marten Lohstroh, Christian Menard.
 * "Consistency vs. Availability in Distributed Cyber-Physical Systems". ACM Transactions on
 * Embedded Computing Systems (TECS), September 2023. https://dl.acm.org/doi/10.1145/3609119
 *
 * This program has two `Sense` sources of events, `s1` and `s2` with identical periods of 1s.
 * The `s1` output is processed by the `Process` reactor, which takes at least 35ms to
 * process the data (emulated by sleeping). As a consequence of this processing latency, were it not
 * for the 200ms `after` delay, the 30ms deadline of the `Actuate` reactor would be violated every
 * time. The deadline is on the second reaction, which cannot be invoked before the first reaction
 * when both reactions are enabled.
 *
 * The deadline is an availability requirement, the `after` delay is a tolerance for inconsistency,
 * and the 35ms processing time is a latency (The C A L in CAL). As long as the actual latency is not greater than the
 * 200ms tolerance for inconsistency plus the 30ms tolerance for unavailability, then availability
 * requirement will be met.
 *
 * Removing or reducing the after delay strengthens consistency but causes deadline violations.
 *
 * This program uses centralized coordination, so if the processing latency plus communication
 * latency exceeds the 200ms tolerance for inconsistency and the 30ms tolerance for unavailability
 * (the deadline), then the coordinator will preserve consistency at the expense of availability.
 * I.e., the deadline will be violated.
 *
 * @author Edward A. Lee
 */
target C {
  timeout: 5s
}

preamble {=
  #include "platform.h"
=}

// Produce a counting sequence starting with 1.
reactor Sense(period: time = 1s) {
  state count: int = 1
  output out: int
  timer t(0, period)

  reaction(t) -> out {=
    lf_set(out, self->count++);
  =}
}

// Pass the input unchanged to the output, but take a long time to do it.
reactor Process {
  input in: int
  output out: int

  reaction(in) -> out {=
    lf_sleep(MSEC(35));
    lf_set(out, in->value);
  =}
}

// Report the inputs.
reactor Actuate {
  input in1: int
  input in2: int

  reaction(in1) {=
    printf(PRINTF_TIME ": Received on in1: %d\n", lf_time_logical_elapsed(), in1->value);
  =}

  reaction(in2) {=
    printf(PRINTF_TIME ": Received on in2: %d\n", lf_time_logical_elapsed(), in2->value);
  =} deadline(30 ms) {=
    printf(PRINTF_TIME ": Received on in2: %d", lf_time_logical_elapsed(), in2->value);
    printf("  *** PANIC! Deadline violated!\n");
  =}
}

federated reactor {
  s1 = new Sense()
  s2 = new Sense()
  c1 = new Process()
  a = new Actuate()
  s1.out -> c1.in
  c1.out -> a.in1 after 200 ms
  s2.out -> a.in2
}

@erlingrj
Copy link
Collaborator Author

erlingrj commented Oct 5, 2023

You have to check out the lingua-franca branch corresponding to this to get it to compile: do git checkout c-remove-deprecated-schedulers && git submodule update

The test runs fine on my end

@erlingrj erlingrj changed the title Remove deprecated schedulers Fix GEDF_NP and remove deprecated schedulers Oct 5, 2023
@erlingrj erlingrj merged commit 5bbdefd into main Oct 6, 2023
@lhstrh lhstrh changed the title Fix GEDF_NP and remove deprecated schedulers Fixed GEDF_NP and removal of deprecated schedulers Jan 23, 2024
@lhstrh lhstrh deleted the remove-deprecated-scheds branch February 1, 2024 20:29
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants