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

Safe handling of physical actions in single-threaded C runtime #1348

Merged
merged 41 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ab16048
Fix lock-time single-threaded build on Linux.
petervdonovan Sep 2, 2022
0bab986
Update submodule
lhstrh Sep 3, 2022
a99989f
Update submodule
lhstrh Sep 3, 2022
cbe7e5a
Update submodule
lhstrh Sep 3, 2022
a949a7d
Merge remote-tracking branch 'origin/master' into lock-time
lhstrh Sep 3, 2022
0fba7da
Update submodule
lhstrh Sep 3, 2022
34be2c2
Update submodule
lhstrh Sep 3, 2022
1e5b58d
Update submodule
lhstrh Sep 3, 2022
8c7fa17
Update submodule
lhstrh Sep 3, 2022
c662e32
Update submodule
lhstrh Sep 3, 2022
73f921d
Update submodule
lhstrh Sep 3, 2022
c1897b2
Update submodule
lhstrh Sep 3, 2022
5a41021
Update submodule
lhstrh Sep 3, 2022
6cb5808
Update submodule; fix typo.
Sep 4, 2022
1f291a1
Update submodule.
Sep 4, 2022
6aba5db
Update submodule.
Sep 4, 2022
74a80cf
Update submodule.
Sep 4, 2022
308035a
Update submodule.
petervdonovan Sep 4, 2022
af471d9
Address LSP test failures.
petervdonovan Sep 4, 2022
e67c93b
Update submodule.
petervdonovan Sep 4, 2022
b38cd7a
Update submodule
lhstrh Sep 8, 2022
f8200d9
Fix conflict
lhstrh Sep 8, 2022
0e5636c
Update submodule
lhstrh Sep 8, 2022
739cb0b
Update submodule
lhstrh Sep 9, 2022
8c81769
Update submodule
lhstrh Sep 9, 2022
892750e
Update submodule
lhstrh Sep 9, 2022
0fe3be6
Adjust tests that used lf_nanosleep
lhstrh Sep 9, 2022
a83bebd
Update submodules
lhstrh Sep 12, 2022
0f33a65
Merge master into lock-time
lhstrh Dec 1, 2022
d5cd82f
Add NRF52 as platform, remove Arduino 32bit stuff
erlingrj Dec 2, 2022
962ffe7
Add THREADED and UNTHREADED to cmake generator
erlingrj Dec 11, 2022
be0882f
Merge branch 'master' into lock-time
erlingrj Dec 21, 2022
bff30f0
Update trace macro
erlingrj Dec 21, 2022
f0491ce
Merge branch 'master' into c-lock-time
erlingrj Dec 21, 2022
d23715e
Update trace macro
erlingrj Dec 21, 2022
efb947d
Bump reactor-c
erlingrj Dec 21, 2022
6bf0565
Merge branch 'c-lock-time' into lock-time
erlingrj Dec 22, 2022
931b2b0
Bump reactor-c
erlingrj Dec 22, 2022
09c77bb
Bump reactor-c
erlingrj Dec 22, 2022
98cd2dd
Merge branch 'master' into lock-time
erlingrj Dec 22, 2022
62e3c0e
Bump reactor-c-py
erlingrj Dec 22, 2022
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
2 changes: 1 addition & 1 deletion org.lflang/src/lib/c/reactor-c
1 change: 1 addition & 0 deletions org.lflang/src/org/lflang/TargetProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,7 @@ public String toString() {
public enum Platform {
AUTO,
ARDUINO("Arduino"),
NRF52("Nrf52"),
LINUX("Linux"),
MAC("Darwin"),
WINDOWS("Windows");
Expand Down
4 changes: 2 additions & 2 deletions org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ CodeBuilder generateCMakeCode(
// Add additional flags so runtime can distinguish between multi-threaded and single-threaded mode
if (targetConfig.threading) {
cMakeCode.pr("# Set flag to indicate a multi-threaded runtime");
cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC LF_MULTI_THREADED)");
cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC LF_THREADED=1)");
} else {
cMakeCode.pr("# Set flag to indicate a single-threaded runtime");
cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC LF_SINGLE_THREADED)");
cMakeCode.pr("target_compile_definitions( ${LF_MAIN_TARGET} PUBLIC LF_UNTHREADED=1)");
}
cMakeCode.newLine();

Expand Down
5 changes: 2 additions & 3 deletions org.lflang/src/org/lflang/generator/c/CGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,7 @@ private void pickCompilePlatform() {
// if platform target was set, use given platform instead
if (targetConfig.platformOptions.platform != Platform.AUTO) {
osName = targetConfig.platformOptions.platform.toString();
}
if (Stream.of("mac", "darwin", "win", "nux", "arduino").noneMatch(osName::contains)) {
} else if (Stream.of("mac", "darwin", "win", "nux").noneMatch(osName::contains)) {
errorReporter.reportError("Platform " + osName + " is not supported");
}
}
Expand Down Expand Up @@ -1831,7 +1830,7 @@ public void processProtoFile(String filename, CancelIndicator cancelIndicator) {
List.of("--c_out="+this.fileConfig.getSrcGenPath(), filename),
fileConfig.srcPath);
if (protoc == null) {
errorReporter.reportError("Processing .proto files requires proto-c >= 1.3.3.");
errorReporter.reportError("Processing .proto files requires protoc-c >= 1.3.3.");
return;
}
var returnCode = protoc.run(cancelIndicator);
Expand Down
11 changes: 6 additions & 5 deletions org.lflang/src/org/lflang/generator/c/CPreambleGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ public static String generateDefineDirectives(
code.pr("#define LOG_LEVEL " + logLevel);
code.pr("#define TARGET_FILES_DIRECTORY " + addDoubleQuotes(srcGenPath.toString()));

if (targetConfig.platformOptions.platform == Platform.ARDUINO) {
code.pr("#define MICROSECOND_TIME");
code.pr("#define BIT_32");
}
if (isFederated) {
code.pr("#define NUMBER_OF_FEDERATES " + numFederates);
code.pr(generateFederatedDefineDirective(coordinationType));
Expand All @@ -100,14 +96,19 @@ public static String generateDefineDirectives(
}
}
if (tracing != null) {
targetConfig.compileDefinitions.put("LINGUA_FRANCA_TRACE", tracing.traceFileName);
targetConfig.compileDefinitions.put("LF_TRACE", tracing.traceFileName);
}
if (clockSyncIsOn) {
code.pr(generateClockSyncDefineDirective(
targetConfig.clockSync,
targetConfig.clockSyncOptions
));
}
if (targetConfig.threading) {
targetConfig.compileDefinitions.put("LF_THREADED", "1");
} else {
targetConfig.compileDefinitions.put("LF_UNTHREADED", "1");
}
code.newLine();
return code.toString();
}
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/ManualDelayedReaction.lf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ reactor Source {
output out: int
timer t

// reaction(t) -> out after 100 msec {=
// reaction(t) -> out after 100 msec
reaction(t) -> out {= lf_set(out, 1); =}
}

Expand Down
2 changes: 1 addition & 1 deletion test/C/src/SimpleDeadline.lf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ main reactor SimpleDeadline {

reaction(start) -> d.x {=
instant_t sleep_time_ns = 20000000;
lf_nanosleep(sleep_time_ns);
lf_sleep(sleep_time_ns);
lf_set(d.x, 42);
=}
}
2 changes: 1 addition & 1 deletion test/C/src/concurrent/AsyncCallback.lf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ main reactor AsyncCallback {
// Simulate time passing before a callback occurs.
void* take_time(void* a) {
instant_t sleep_time = 100000000;
lf_nanosleep(sleep_time);
lf_sleep(sleep_time);
callback(a);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/concurrent/AsyncCallbackDrop.lf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ main reactor {
// Simulate time passing before a callback occurs.
void* take_time(void* a) {
instant_t sleep_time = 100000000;
lf_nanosleep(sleep_time);
lf_sleep(sleep_time);
callback(a);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/concurrent/AsyncCallbackReplace.lf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ main reactor {
// Simulate time passing before a callback occurs.
void* take_time(void* a) {
instant_t sleep_time = 100000000;
lf_nanosleep(sleep_time);
lf_sleep(sleep_time);
callback(a);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/federated/DistributedPhysicalActionUpstream.lf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ preamble {=
void* take_time(void* a) {
while (_counter < 15) {
instant_t sleep_time = MSEC(10);
lf_nanosleep(sleep_time);
lf_sleep(sleep_time);
callback(a);
}
return NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ preamble {=
void* take_time(void* a) {
while (_counter < 20) {
instant_t sleep_time = USEC(50);
lf_nanosleep(sleep_time);
lf_sleep(sleep_time);
callback(a);
}
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/federated/FeedbackDelay.lf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ reactor Planner {
output response: double

reaction(request) -> response {=
lf_nanosleep(MSEC(10));
lf_sleep(MSEC(10));
SET(response, request->value);
=}
}
Expand Down
2 changes: 1 addition & 1 deletion test/Python/src/ManualDelayedReaction.lf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ reactor Source {
output out
timer t

reaction(t) -> out {= out.set(1) =} # reaction(t) -> out after 100 msec {=
reaction(t) -> out {= out.set(1) =} # reaction(t) -> out after 100 msec
}

reactor Sink {
Expand Down
2 changes: 1 addition & 1 deletion util/tracing/trace_to_chrome.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* for viewing in Chrome's event visualizer. To visualize the resulting file,
* point your chrome browser to chrome://tracing/ and the load the .json file.
*/
#define LINGUA_FRANCA_TRACE
#define LF_TRACE
#include "reactor.h"
#include "trace.h"
#include "trace_util.h"
Expand Down
2 changes: 1 addition & 1 deletion util/tracing/trace_to_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Standalone program to convert a Lingua Franca trace file to a comma-separated values
* text file.
*/
#define LINGUA_FRANCA_TRACE
#define LF_TRACE
#include "reactor.h"
#include "trace.h"
#include "trace_util.h"
Expand Down
2 changes: 1 addition & 1 deletion util/tracing/trace_to_influxdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* The data can then be viewed in the InfluxDB browser, or you can configure an external
* tool such as Grafana to visualize it (see https://grafana.com/docs/grafana/latest/datasources/influxdb/).
*/
#define LINGUA_FRANCA_TRACE
#define LF_TRACE
#include "reactor.h"
#include "trace.h"
#include "trace_util.h"
Expand Down
2 changes: 1 addition & 1 deletion util/tracing/trace_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Standalone program to convert a Lingua Franca trace file to a comma-separated values
* text file.
*/
#define LINGUA_FRANCA_TRACE
#define LF_TRACE
#include "reactor.h"
#include "trace.h"
#include "trace_util.h"
Expand Down
2 changes: 1 addition & 1 deletion util/tracing/trace_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Header file for common utilities used in converting Lingua Franca trace files
* into other formats.
*/
#define LINGUA_FRANCA_TRACE
#define LF_TRACE
#include "reactor.h"
#include "trace.h"

Expand Down