Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fixed bug in modes with microsteps #2338

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions test/C/src/concurrent/ModesWithWatchdog.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* When in the Primary mode, the watchdog is sure to trigger, causing the reaction to watcher to be
* executed one microstep later. Previously, after a mode transition, the microstep was hardwired to
* 1, which caused a fatal error after the mode transition when the runtime tried to advance to
* microstep 1 and found that it was already at microstep 1. This program tests that this is fixed.
* Success is simply running to completion without error.
*/
target C {
keepalive: true,
timeout: 1 s
}

reactor Arbitrator(timeout: time = 100 ms) {
input in1: double
input in2: double

watchdog watcher(timeout) {= lf_print("watchdog timeout."); =}

initial mode Primary {
reaction(in1) -> watcher {=
lf_watchdog_start(watcher, 0);
=}

reaction(watcher) -> reset(Backup) {=
lf_print("watchdog reaction.");
lf_set_mode(Backup);
=}
}

mode Backup {
reaction(in2) -> watcher {=
lf_watchdog_start(watcher, 0);
=}
}
}

main reactor {
timer t(0, 100 ms)

ar = new Arbitrator()

reaction(t) -> ar.in1, ar.in2 {=
lf_set(ar.in1, 0.0);
lf_set(ar.in2, 0.0);
=}
}