-
Notifications
You must be signed in to change notification settings - Fork 1
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
Code-generate for federated programs #175
base: main
Are you sure you want to change the base?
Conversation
But invoking CMake correctly to generate two binaries and a shell script in `bin` is not working
Memory usage after merging this PR will be: Memory Reportaction_empty_test_c
action_microstep_test_c
action_overwrite_test_c
action_test_c
deadline_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
nanopb_test_c
port_test_c
reaction_queue_test_c
request_shutdown_test_c
startup_test_c
tcp_channel_test_c
timer_test_c
|
Benchmark results after merging this PR: Benchmark resultsPerformance:PingPongUc: PingPongC: ReactionLatencyUc: ReactionLatencyC: Memory usage:PingPongUc: PingPongC: ReactionLatencyUc: ReactionLatencyC: |
examples/riot/hello_lf/run/build.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LasseRosenow is this needed?
include/reactor-uc/environment.h
Outdated
@@ -9,6 +9,7 @@ | |||
#include "reactor-uc/scheduler.h" | |||
|
|||
typedef struct Environment Environment; | |||
extern Environment *_lf_environment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created this global backdoor so that the logging functions could read out the current time and add it to the printouts... we could possibly use this also within the TcpIpChannel and UdpCoapChannel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you mean we remove the Environment pointer
from the constructor and just use the global pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is possible. It is a little dirty, but, having global access to the environment also makes sense.
@@ -78,7 +78,7 @@ if (NOT PLATFORM STREQUAL "ZEPHYR") | |||
endif() | |||
|
|||
# Add compile definitions for platform and network channel specifics. | |||
target_compile_definitions(reactor-uc PRIVATE "PLATFORM_${PLATFORM}") | |||
target_compile_definitions(reactor-uc PUBLIC "PLATFORM_${PLATFORM}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PLATFORM compile def must be visible in targets that link to reactor-uc also, because they will include the network_channel.h where it is used
@@ -49,7 +49,11 @@ interval_t Environment_get_physical_time(Environment *self) { | |||
return self->platform->get_physical_time(self->platform); | |||
} | |||
interval_t Environment_get_elapsed_physical_time(Environment *self) { | |||
return self->platform->get_physical_time(self->platform) - self->scheduler->start_time; | |||
if (self->scheduler->start_time == NEVER) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support reading out elapsed physical time even before we have started
@@ -150,7 +155,7 @@ void FederatedInputConnection_ctor(FederatedInputConnection *self, Reactor *pare | |||
self->delay = delay; | |||
self->type = type; | |||
self->last_known_tag = NEVER_TAG; | |||
self->safe_to_assume_absent = FOREVER; | |||
self->safe_to_assume_absent = 0; // FIXME: This should be set by the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I change the default here. By setting this to 0 we move from a dataflow federation to a "poor-mans-ptides" where the after-delays on the federated connections should be greater than the actual network delays
break; | ||
case LF_PAST_TAG: | ||
LF_WARN(FED, "Tried scheduling event to a past tag. Dropping\n"); | ||
LF_ERR(FED, "Safe-to-process violation! Tried scheduling event to a past tag. Handling now instead!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we receive an event destined for a past tag, then instead of dropping it, we handle it ASAP. In the future we will add support for a handler for this case, just like the deadlines
@@ -29,7 +29,8 @@ static struct timespec convert_ns_to_timespec(instant_t time) { | |||
} | |||
|
|||
lf_ret_t PlatformPosix_initialize(Platform *_self) { | |||
signal(SIGINT, handle_ctrlc); | |||
signal(SIGINT, handle_signal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle both ctrl-c and SIGTERM and stop the program
NetworkChannel_state_to_string(new_state)); | ||
|
||
pthread_mutex_lock(&self->mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here a mutex is used as a straightforward way of protecting this shared state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
TODOs:
bin
together with a simple shell script to invoke them (just like reactor-c)SimpleFederate_r
for a program calledSimpleFederate.lf
and a federate instance calledr
.