From 1b3b567ce257d5eb1d6675ea16cc2795b06aeffb Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Fri, 28 Jun 2024 15:29:25 -0700 Subject: [PATCH 1/4] Added test for reactor-c modes-with-microsteps --- core/src/main/resources/lib/c/reactor-c | 2 +- test/C/src/modal_models/ModesWithWatchdog.lf | 46 ++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/C/src/modal_models/ModesWithWatchdog.lf diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 587a8f9498..33e7c20ddb 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 587a8f9498b69bc82f404e432f881d7bb0bcf383 +Subproject commit 33e7c20ddb052e9370e66b32a8232dd8195d6bb7 diff --git a/test/C/src/modal_models/ModesWithWatchdog.lf b/test/C/src/modal_models/ModesWithWatchdog.lf new file mode 100644 index 0000000000..8cec971ff5 --- /dev/null +++ b/test/C/src/modal_models/ModesWithWatchdog.lf @@ -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); + =} +} From 16a28f7b491c281d1c6cbdee4518f1d3fa3e284e Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Fri, 28 Jun 2024 15:29:54 -0700 Subject: [PATCH 2/4] Format --- test/C/src/modal_models/ModesWithWatchdog.lf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/C/src/modal_models/ModesWithWatchdog.lf b/test/C/src/modal_models/ModesWithWatchdog.lf index 8cec971ff5..bd23d0625b 100644 --- a/test/C/src/modal_models/ModesWithWatchdog.lf +++ b/test/C/src/modal_models/ModesWithWatchdog.lf @@ -1,9 +1,9 @@ /** - * 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. + * 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, From a9e8db3b41a5f7df4f6646921b1d8a191199dd82 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sat, 29 Jun 2024 07:01:44 -0700 Subject: [PATCH 3/4] Moved test because it cannot run without threads --- core/src/main/resources/lib/c/reactor-c | 2 +- test/C/src/{modal_models => concurrent}/ModesWithWatchdog.lf | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename test/C/src/{modal_models => concurrent}/ModesWithWatchdog.lf (100%) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 33e7c20ddb..5ac0a0b3b0 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 33e7c20ddb052e9370e66b32a8232dd8195d6bb7 +Subproject commit 5ac0a0b3b0759910e8397590c614e86652021b44 diff --git a/test/C/src/modal_models/ModesWithWatchdog.lf b/test/C/src/concurrent/ModesWithWatchdog.lf similarity index 100% rename from test/C/src/modal_models/ModesWithWatchdog.lf rename to test/C/src/concurrent/ModesWithWatchdog.lf From b76e9dfd32b100287e70ea75bdc667820a13ea07 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Mon, 1 Jul 2024 01:49:28 -0700 Subject: [PATCH 4/4] Update reactor-c submodule --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 5ac0a0b3b0..7a0808717e 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 5ac0a0b3b0759910e8397590c614e86652021b44 +Subproject commit 7a0808717eacfbfeb9aa5a8a4e4e50291e2bad63