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

Stopping problems with decentralized coordination #473

Open
edwardalee opened this issue Aug 2, 2024 · 0 comments
Open

Stopping problems with decentralized coordination #473

edwardalee opened this issue Aug 2, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@edwardalee
Copy link
Contributor

Decentralized coordination is having difficulty coordinating the shutdown of a federation when a federate calls lf_request_stop(). The following program executes at tags (0,0) through (0,3) (four cycles), at which point the Gather reactor calls lf_request_stop() and schedules one more cycle to occur at (0,4). This will likely be the stop tag that the RTI selects, although in theory it is possible for the RTI to select a later stop tag. However, this fifth cycle is usually not completing correctly. The sockets between federates appear to get closed prematurely from the sending end.

target C {
  coordination: decentralized,
}
reactor Pi {
  input trigger: bool
  output out: int
  reaction(trigger) -> out {=
    tag_t now = lf_tag();
    lf_print("***** at tag " PRINTF_TAG, now.time - lf_time_start(), now.microstep);
    lf_set(out, 42);
  =} STP (30 s) {=
    tag_t now = lf_tag();
    lf_print_error_and_exit("STP violation at Pi at tag " PRINTF_TAG, now.time - lf_time_start(), now.microstep);
  =}
}
reactor Gather {
  input[4] in: int
  output next: bool
  logical action a
  state count: int = 0
  reaction(startup, a) -> next {=
    lf_set(next, true);
  =}
  reaction(in) -> a {=
    tag_t now = lf_tag();
    for (int i = 0; i < 4; i++) {
      if (!in[i]->is_present) {
        lf_print_error_and_exit("Missing input %d in Gather at tag " PRINTF_TAG,
            i, now.time - lf_time_start(), now.microstep);
      }
    }
    lf_print("%d: at tag " PRINTF_TAG, self->count, now.time - lf_time_start(), now.microstep);
    self->count++;
    if (self->count == 4) {
      lf_request_stop();
    }
    lf_schedule(a, 0);
  =} STP (30 s) {=
    tag_t now = lf_tag();
    lf_print_error_and_exit("STP violation at Gather at tag " PRINTF_TAG, now.time - lf_time_start(), now.microstep);
  =}
  reaction(shutdown) {=
    if (self->count < 5) {
      lf_print_error_and_exit("Gather received only %d inputs. Expected at least 5.", self->count);
    } 
  =}
}
federated reactor {
  pi = new[4] Pi()
  g = new Gather()
  pi.out -> g.in
  (g.next)+ -> pi.trigger
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant