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

Adding support of transient federates #358

Draft
wants to merge 93 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
bc66d28
Start on adding federate type (transient or not)
ChadliaJerad Feb 1, 2024
6bf9703
Add cmdline argument -nt to RTI and add nbr_transient_federates attri…
ChadliaJerad Feb 1, 2024
d6c8b22
Differentiate between connecting to persistent federates and transien…
ChadliaJerad Feb 1, 2024
e9d1f1f
Differentiate between connecting to persistent federates and transien…
ChadliaJerad Feb 1, 2024
2d437a7
Add support of the effective_start_tag
ChadliaJerad Feb 1, 2024
0bfd0a0
Add support of the effective_start_tag cont.
ChadliaJerad Feb 1, 2024
14647e1
Federate shares its type (persistent or transient)
ChadliaJerad Feb 1, 2024
9bf9659
Add federation life cycle phase
ChadliaJerad Feb 5, 2024
b78f02a
Make the federate read the effective start tag
ChadliaJerad Feb 14, 2024
80602ea
Drop the messages intended for a transient federate that is connected…
ChadliaJerad Feb 15, 2024
d0560d2
Granting TAG or PTAGs can be delayed if one of the upstream federates…
ChadliaJerad Feb 15, 2024
13aa463
When all upstream federates are not connected (transients), then the …
ChadliaJerad Feb 15, 2024
45d2e03
Only persistent federates are accounted for requesting stop
ChadliaJerad Feb 15, 2024
c779428
Compute and send the effective start tag of a joining transient
ChadliaJerad Feb 15, 2024
d939e7b
Start on enabling the hot swap mechanism
ChadliaJerad Feb 15, 2024
1b0b491
More on the hot swap mechanism + various fixes
ChadliaJerad Feb 15, 2024
26dbcb8
RTI can sent a request for immediate stop. This is required by the ho…
ChadliaJerad Feb 15, 2024
07ecaa9
Federate processes a stop request by the RTI
ChadliaJerad Feb 16, 2024
55bbf5c
Stop the execution of a federate
ChadliaJerad Feb 16, 2024
1a24c06
Add lf_get_federates_bin_directory.
petervdonovan Aug 4, 2023
63bcecf
A federate can get its id, its effective_start_time, and the start_ti…
ChadliaJerad Feb 16, 2024
f32ec0a
Add MST_TYPE_TIMESTAMP_START and its length
ChadliaJerad Feb 17, 2024
facf3bc
Fix the use of lf_stop()
ChadliaJerad Feb 19, 2024
4118ce3
Fix send_start_tag() to account for the effective start tag
ChadliaJerad Feb 19, 2024
af5e70d
Fix for transient connection
ChadliaJerad Feb 20, 2024
f66c756
Fix the initialization of the effective start tag
ChadliaJerad Feb 20, 2024
b186998
Adjust doc
ChadliaJerad Feb 20, 2024
e9aade5
Adjust 2 debug messages in RTI
ChadliaJerad Feb 20, 2024
3b054f3
Attemp to fix the hot swap mechanism
ChadliaJerad Feb 20, 2024
0e3aa45
Remove overlooked instruction
ChadliaJerad Feb 20, 2024
0ce2917
Augment fedsd to acount for transient federates
ChadliaJerad Feb 20, 2024
069d581
Minor fixes
ChadliaJerad Feb 20, 2024
3008e66
Fix lingua-france-ref.txt
ChadliaJerad Feb 20, 2024
fc1a14c
Fix void* returns
ChadliaJerad Feb 20, 2024
5d578d5
Fix based on code review
ChadliaJerad Feb 23, 2024
553a3e4
Make immediate and delayed (p)tag notification functions
ChadliaJerad Feb 23, 2024
227c1b5
Control the type and value of the number of transients
ChadliaJerad Feb 23, 2024
20cc4f5
The number of transients should not be greater or equal to the number…
ChadliaJerad Feb 29, 2024
fb8bf63
Remove wrongly duplicated code
ChadliaJerad Feb 29, 2024
35b8907
Code review: remove redundancy and add has_transient_upstream_federats
ChadliaJerad Feb 29, 2024
6ebb401
Fix the call to tracepoint() to account for the refactoring of the tr…
ChadliaJerad Feb 29, 2024
241fd02
Code review: Fix extra characters in comment
ChadliaJerad Feb 29, 2024
5501870
Fix a call to tracepoint
ChadliaJerad Feb 29, 2024
86a5582
Change _lf_fed_STA_offset to lf_fed_STA_offset and _lf_set_stop_tag t…
ChadliaJerad Feb 29, 2024
70f3c80
Fix the call to tracepoint in federate.c
ChadliaJerad Feb 29, 2024
d0596d1
Add comments and more formatting
ChadliaJerad Mar 14, 2024
5975c39
Fix bugs due to rebase + Tracepoint lf_stop()
ChadliaJerad Mar 14, 2024
b33b863
Code review: document that MSG_TYPE_FED_IDS include the type of the f…
ChadliaJerad Mar 14, 2024
2530145
Add return NULL in void* functions
ChadliaJerad Mar 14, 2024
993ef1d
Use a tag queue to manage delayed grants
ChadliaJerad Mar 3, 2024
6e22c28
Fix missing code from the previous commit
ChadliaJerad Mar 15, 2024
2b3548d
Fix the type of max_number_of_delayed_grants
ChadliaJerad Mar 3, 2024
bfe3965
Fix return void *
ChadliaJerad Mar 4, 2024
786acc8
Fix the use of condition variabale updated_delayed_grants
ChadliaJerad Mar 4, 2024
79a5039
Add documentation to lf_delayed_grants_thread() and adjust the exit c…
ChadliaJerad Mar 4, 2024
bb6b70c
Fix the segmentation fault hapening when a second hot swap mechanism …
ChadliaJerad Mar 11, 2024
8d7e414
Improve memory management when dealing with transients
ChadliaJerad Mar 11, 2024
f51f031
Make sure the transient federate interface did not change when a new …
ChadliaJerad Mar 11, 2024
a0bf3b2
Fix the segmentation fault error of the RTI
ChadliaJerad Mar 18, 2024
f7b7539
Fix the exit of th thread that connects to transients
ChadliaJerad Mar 18, 2024
4dbb6d7
Logging of the delayed grants queue activity
ChadliaJerad Mar 18, 2024
7100702
Consistent naming: use lf_tag_effective_start() instead of lf_get_eff…
ChadliaJerad Mar 18, 2024
1993da4
Fix log message
ChadliaJerad Mar 18, 2024
7b66c6f
Attempt to solve another segmentation fault
ChadliaJerad Mar 18, 2024
f91081d
Fix implicit declaration error by moving lf_stop(), lf_get_federates_…
ChadliaJerad Mar 18, 2024
f8979c3
Merge branch 'main' into transient-fed
ChadliaJerad Apr 12, 2024
a7ffdaf
Fix merge
ChadliaJerad Apr 12, 2024
b8f63d0
Merge branch 'transient-fed' into transient-fed-use-pqueue
ChadliaJerad Apr 12, 2024
884e65c
Fix warnings (turned as errors)
ChadliaJerad Apr 15, 2024
fcff552
Merge branch 'main' into transient-fed-use-pqueue
ChadliaJerad Apr 15, 2024
91266da
Fix variable name
ChadliaJerad Apr 15, 2024
dfb48f3
Merge branch 'main' into transient-fed-use-pqueue
ChadliaJerad Apr 24, 2024
812c2ce
Fix the documentation of MSG_TYPE_FED_IDS to describe the federate ty…
ChadliaJerad Apr 24, 2024
2c6a136
Augment the documentation of receive_connection_information() to desc…
ChadliaJerad Apr 24, 2024
da9a990
Invalidate upstream delays when a transient leaves the federation
ChadliaJerad Apr 24, 2024
07d043f
Fix the invalidation
ChadliaJerad Apr 25, 2024
81ad8a1
Upadte the computatio of the effective start tag to account for upstr…
ChadliaJerad May 8, 2024
3c90f79
Merge branch 'main' into transient-fed-use-pqueue
ChadliaJerad May 8, 2024
783ccec
Merge branch 'main' into transient-fed
ChadliaJerad May 18, 2024
5e6b03d
Merge branch 'transient-fed' into transient-fed-use-pqueue
ChadliaJerad May 18, 2024
011a9d6
Merge branch 'main' into transient-fed-use-pqueue
ChadliaJerad Jun 13, 2024
f38568f
Get the max of the TAG of the upstreams only if the queue is not empty
ChadliaJerad Jun 19, 2024
ac3c4b7
Fix return value of lf_get_federates_bin_directory()
ChadliaJerad Jun 19, 2024
bb5d375
Another attempt to fix return value of lf_get_federates_bin_directory()
ChadliaJerad Jun 19, 2024
71d706b
Another attempt to fix return value of lf_get_federates_bin_directory()
ChadliaJerad Jun 20, 2024
59d4279
Merge branch 'main' into transient-fed
edwardalee Jul 10, 2024
e84ec76
Merge branch 'transient-fed' into transient-fed-use-pqueue
edwardalee Jul 10, 2024
847f94b
Fixed slipped merge conflict
edwardalee Jul 10, 2024
9fcf524
Merge branch 'transient-fed' into transient-fed-use-pqueue
edwardalee Jul 10, 2024
e7fefe3
Merge pull request #394 from lf-lang/transient-fed-use-pqueue
edwardalee Jul 10, 2024
b0b0ea6
Merge branch 'main' into transient-fed
ChadliaJerad Jul 24, 2024
3408e35
Merge branch 'main' into transient-fed
ChadliaJerad Aug 7, 2024
1d06d53
Merge branch 'main' into transient-fed
ChadliaJerad Aug 14, 2024
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
1 change: 1 addition & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ define(SCHEDULER)
define(LF_SOURCE_DIRECTORY)
define(LF_SOURCE_GEN_DIRECTORY)
define(LF_PACKAGE_DIRECTORY)
define(LF_FEDERATES_BIN_DIRECTORY)
define(LF_FILE_SEPARATOR)
define(WORKERS_NEEDED_FOR_FEDERATE)
define(LF_ENCLAVES)
32 changes: 30 additions & 2 deletions core/federated/RTI/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ void usage(int argc, const char* argv[]) {
lf_print(" The ID of the federation that this RTI will control.\n");
lf_print(" -n, --number_of_federates <n>");
lf_print(" The number of federates in the federation that this RTI will control.\n");
lf_print(" -nt, --number_of_transient_federates <n>");
lf_print(" The number of federates that are transient; this must be strictly less than the number of federates.\n");
lf_print(" -p, --port <n>");
lf_print(" The port number to use for the RTI. Must be larger than 0 and smaller than %d. Default is %d.\n",
UINT16_MAX, DEFAULT_PORT);
Expand Down Expand Up @@ -232,6 +234,21 @@ int process_args(int argc, const char* argv[]) {
}
rti.base.number_of_scheduling_nodes = (int32_t)num_federates; // FIXME: Loses numbers on 64-bit machines
lf_print("RTI: Number of federates: %d", rti.base.number_of_scheduling_nodes);
} else if (strcmp(argv[i], "-nt") == 0 || strcmp(argv[i], "--number_of_transient_federates") == 0) {
if (argc < i + 2) {
lf_print_error("--number_of_transient_federates needs a valid positive argument.");
usage(argc, argv);
return 0;
}
i++;
long num_transient_federates = strtol(argv[i], NULL, 10);
if (num_transient_federates < 0L || num_transient_federates == LONG_MAX || num_transient_federates == LONG_MIN) {
lf_print_error("--number_of_transient_federates needs a valid positive or null integer argument.");
usage(argc, argv);
return 0;
}
rti.number_of_transient_federates = (int32_t)num_transient_federates; // FIXME: Loses numbers on 64-bit machines
lf_print("RTI: Number of transient federates: %d", rti.number_of_transient_federates);
} else if (strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--port") == 0) {
if (argc < i + 2) {
lf_print_error("--port needs a short unsigned integer argument ( > 0 and < %d).", UINT16_MAX);
Expand Down Expand Up @@ -272,8 +289,19 @@ int process_args(int argc, const char* argv[]) {
return 0;
}
}
if (rti.base.number_of_scheduling_nodes == 0) {
lf_print_error("--number_of_federates needs a valid positive integer argument.");
usage(argc, argv);
return 0;
}
if (rti.number_of_transient_federates >= rti.base.number_of_scheduling_nodes) {
lf_print_error("--number_of_transient_federates cannot be higher or equal to the number of federates.");
usage(argc, argv);
return 0;
}
return 1;
}

int main(int argc, const char* argv[]) {
initialize_lf_thread_id();
initialize_RTI(&rti);
Expand Down Expand Up @@ -311,8 +339,8 @@ int main(int argc, const char* argv[]) {
lf_print("Tracing the RTI execution in %s file.", rti_trace_file_name);
}

lf_print("Starting RTI for %d federates in federation ID %s.", rti.base.number_of_scheduling_nodes,
rti.federation_id);
lf_print("Starting RTI for a total of %d federates, with %d being transient, in federation ID %s",
rti.base.number_of_scheduling_nodes, rti.number_of_transient_federates, rti.federation_id);
assert(rti.base.number_of_scheduling_nodes < UINT16_MAX);

// Allocate memory for the federates
Expand Down
15 changes: 13 additions & 2 deletions core/federated/RTI/rti_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ tag_t eimt_strict(scheduling_node_t* e) {
tag_advance_grant_t tag_advance_grant_if_safe(scheduling_node_t* e) {
tag_advance_grant_t result = {.tag = NEVER_TAG, .is_provisional = false};

// Check how many upstream federates are connected
int num_connected_upstream = 0;

// Find the earliest LTC of upstream scheduling_nodes (M).
tag_t min_upstream_completed = FOREVER_TAG;

Expand All @@ -164,6 +167,7 @@ tag_advance_grant_t tag_advance_grant_if_safe(scheduling_node_t* e) {
// Ignore this enclave/federate if it is not connected.
if (upstream->state == NOT_CONNECTED)
continue;
num_connected_upstream++;

// Adjust by the "after" delay.
// Note that "no delay" is encoded as NEVER,
Expand All @@ -176,8 +180,15 @@ tag_advance_grant_t tag_advance_grant_if_safe(scheduling_node_t* e) {
}
LF_PRINT_LOG("RTI: Minimum upstream LTC for federate/enclave %d is " PRINTF_TAG "(adjusted by after delay).", e->id,
min_upstream_completed.time - start_time, min_upstream_completed.microstep);
if (lf_tag_compare(min_upstream_completed, e->last_granted) > 0 &&
lf_tag_compare(min_upstream_completed, e->next_event) >= 0 // The enclave has to advance its tag

if (num_connected_upstream == 0) {
// When none of the upstream federates is connected (case of transients),
if (lf_tag_compare(e->next_event, FOREVER_TAG) != 0) {
result.tag = e->next_event;
return result;
}
} else if (lf_tag_compare(min_upstream_completed, e->last_granted) > 0 &&
lf_tag_compare(min_upstream_completed, e->next_event) >= 0 // The enclave has to advance its tag
) {
result.tag = min_upstream_completed;
return result;
Expand Down
Loading
Loading