lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
220 stars 57 forks source link

Presence of logical action is not reset in C target #2300

Open a-sr opened 4 weeks ago

a-sr commented 4 weeks ago

After being present once the is_present always returns true even if the logical action did not trigger.

Example:

target C {
    timeout: 7 msecs,
    fast: true
}

main reactor {
    logical action a;
    logical action b;

    reaction(startup) -> a {=
        lf_schedule(a, MSEC(1));
    =}

    reaction(a, b) -> a, b {=
        if (a->is_present) {
            printf("A");
            lf_schedule(b, MSEC(2));
        }
        if (b->is_present) {
            printf("B");
            lf_schedule(a, MSEC(1));
        }
        printf(" at %d msecs with triggers (%d,%d)\n", lf_time_logical_elapsed() / MSEC(1), a->is_present, b->is_present);
    =}
}

Output (VS Code v0.7.3):

A at 1 msecs with triggers (1,0)
AB at 3 msecs with triggers (1,1)
AB at 4 msecs with triggers (1,1)
AB at 5 msecs with triggers (1,1)
AB at 6 msecs with triggers (1,1)
AB at 7 msecs with triggers (1,1)

Expected behavior: A and B should alternate with different offsets.

cmnrd commented 4 weeks ago

This is a duplicate of https://github.com/lf-lang/lingua-franca/issues/2291