Skip to content

Commit

Permalink
Fix LongShort
Browse files Browse the repository at this point in the history
  • Loading branch information
lsk567 committed Nov 12, 2024
1 parent c17631d commit 0caa4f9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,23 @@ public PretVmObjectFile generateInstructions(Dag dagParitioned, StateSpaceFragme
}
// Add a label to the first instruction using the exploration phase
// (INIT, PERIODIC, SHUTDOWN_TIMEOUT, etc.).
for (int i = 0; i < workers; i++) {
for (int w = 0; w < workers; w++) {
// First, check if there is any instruction generated.
// A worker without any work assignment has an empty schedule.
if (instructions.get(i).size() > 0)
instructions.get(i).get(0).addLabel(fragment.getPhase().toString());
// In this case, generate a dummy instruction: adding zero to a
// temp register.
// Without this dummy instruction, currently there will be
// compilation errors due to not having a place to put phase labels.
if (instructions.get(w).size() == 0) {
addInstructionForWorker(
instructions,
w,
dagParitioned.end,
null,
new InstructionADD(registers.temp0.get(w), registers.temp0.get(w), registers.zero));
}
// Then assign a label to the first instruction.
instructions.get(w).get(0).addLabel(fragment.getPhase().toString());
}
return new PretVmObjectFile(instructions, fragment, dagParitioned);
}
Expand Down
33 changes: 33 additions & 0 deletions test/C/src/static/LongShort.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
target C {
scheduler: STATIC,
timeout: 5 sec,
workers: 2,
fast: true,
}

realtime reactor Long {
timer t(0, 300 msec)
@wcet("300 msec")
reaction(t) {=
instant_t start = lf_time_physical();
interval_t wait = MSEC(290);
instant_t release = start + wait;
while (lf_time_physical() < release);
=}
}

realtime reactor Short {
timer t(0, 100 msec)
@wcet("100 msec")
reaction(t) {=
instant_t start = lf_time_physical();
interval_t wait = MSEC(90);
instant_t release = start + wait;
while (lf_time_physical() < release);
=}
}

main reactor {
l = new Long()
s = new Short()
}

0 comments on commit 0caa4f9

Please sign in to comment.