Skip to content

Commit

Permalink
#68 Rough support for cyclic execution of BE processes in a window
Browse files Browse the repository at this point in the history
I don't like that this uses the internal Partition::clear_completed_flag method from Slice. I think that a more architecturally sound solution would be to create BePartition and ScPartition subclasses and move as much of the partition-related logic there, as the special cases for SC and BE are starting to pile up a bit inside Slice.
  • Loading branch information
MatejKafka committed Nov 13, 2022
1 parent f6d6435 commit 8154791
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/partition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ 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);

private:
// cyclic queue
void move_to_next_proc();
void clear_completed_flag();
};
12 changes: 9 additions & 3 deletions src/slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,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. */
Expand Down
13 changes: 13 additions & 0 deletions test_config/be_cycle.yaml
Original file line number Diff line number Diff line change
@@ -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<n> 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

0 comments on commit 8154791

Please sign in to comment.