diff --git a/src/partition.hpp b/src/partition.hpp index e5198c37..2647ba22 100644 --- a/src/partition.hpp +++ b/src/partition.hpp @@ -126,6 +126,9 @@ class Partition [[nodiscard]] bool is_empty() const; [[nodiscard]] std::string get_name() const; + /** Clears the completion flags on all processes in this partition. */ + void clear_completed_flag(); + // both called by Process void proc_exit_cb(Process &proc); void completed_cb(Process &proc); @@ -133,5 +136,4 @@ class Partition private: // cyclic queue void move_to_next_proc(); - void clear_completed_flag(); }; diff --git a/src/slice.cpp b/src/slice.cpp index 2f16e8ab..daef5fa8 100644 --- a/src/slice.cpp +++ b/src/slice.cpp @@ -41,12 +41,18 @@ bool Slice::load_next_process(time_point current_time) if (running_process) { return true; } - // no process found, we're done - // call cb if running SC partition + + // no process found if (running_partition == sc) { + // for SC, we're done, call cb sc_done_cb(*this, current_time); + return false; + } else { // be + // for BE, clear the completed flag on all processes, and continue execution with the next + // process; this way, BE processes may run multiple times in a single window + running_partition->clear_completed_flag(); + return load_next_process(current_time); } - return false; } /** Finds and starts next unfinished process from current_partition. */ diff --git a/test_config/be_cycle.yaml b/test_config/be_cycle.yaml new file mode 100644 index 00000000..e1300c97 --- /dev/null +++ b/test_config/be_cycle.yaml @@ -0,0 +1,13 @@ +# Test that BE processes are executed in a cycle even in a single long window. + +partitions: + - name: BE1 + processes: + # changing p indent for better output readability + - {budget: 500, cmd: "while true; do echo 'p1'; sleep 0.1; done"} + - {budget: 500, cmd: "while true; do echo 'p 2'; sleep 0.1; done"} + - {budget: 500, cmd: "while true; do echo 'p 3'; sleep 0.1; done"} + +windows: + - length: 5000 + be_partition: BE1 \ No newline at end of file