Skip to content

Commit

Permalink
Merge pull request #469 from lf-lang/startup-immediately
Browse files Browse the repository at this point in the history
Immediate start of federates with STA offset under decentralized coordination
  • Loading branch information
Depetrol authored Jul 16, 2024
2 parents 4abce72 + 15c07f9 commit 4cdc2f9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions core/threaded/reactor_threaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,16 +615,15 @@ void _lf_initialize_start_tag(environment_t* env) {

#if defined FEDERATED_DECENTRALIZED
// If we have a non-zero STA offset, then we need to allow messages to arrive
// prior to the start time. To avoid spurious STP violations, we temporarily
// at the start time. To avoid spurious STP violations, we temporarily
// set the current time back by the STA offset.
env->current_tag.time -= lf_fed_STA_offset;
LF_PRINT_LOG("Waiting for start time " PRINTF_TIME " plus STA " PRINTF_TIME ".", start_time, lf_fed_STA_offset);
#else
// For other than federated decentralized execution, there is no lf_fed_STA_offset variable defined.
// To use uniform code below, we define it here as a local variable.
instant_t lf_fed_STA_offset = 0;
LF_PRINT_LOG("Waiting for start time " PRINTF_TIME ".", start_time);
#endif
LF_PRINT_LOG("Waiting for start time " PRINTF_TIME ".", start_time);

// Call wait_until if federated. This is required because the startup procedure
// in lf_synchronize_with_other_federates() can decide on a new start_time that is
Expand All @@ -643,7 +642,7 @@ void _lf_initialize_start_tag(environment_t* env) {
// Here we wait until the start time and also release the environment mutex.
// this means that the other worker threads will be allowed to start. We need
// this to avoid potential deadlock in federated startup.
while (!wait_until(start_time + lf_fed_STA_offset, &env->event_q_changed)) {
while (!wait_until(start_time, &env->event_q_changed)) {
};
LF_PRINT_DEBUG("Done waiting for start time + STA offset " PRINTF_TIME ".", start_time + lf_fed_STA_offset);
LF_PRINT_DEBUG("Physical time is ahead of current time by " PRINTF_TIME ". This should be close to the STA offset.",
Expand Down

0 comments on commit 4cdc2f9

Please sign in to comment.