diff --git a/core/src/main/java/org/lflang/analyses/pretvm/InstructionGenerator.java b/core/src/main/java/org/lflang/analyses/pretvm/InstructionGenerator.java index c0b55cd317..46553861a3 100644 --- a/core/src/main/java/org/lflang/analyses/pretvm/InstructionGenerator.java +++ b/core/src/main/java/org/lflang/analyses/pretvm/InstructionGenerator.java @@ -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); } diff --git a/test/C/src/static/LongShort.lf b/test/C/src/static/LongShort.lf new file mode 100644 index 0000000000..17705f9417 --- /dev/null +++ b/test/C/src/static/LongShort.lf @@ -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() +} \ No newline at end of file