Skip to content

Commit c811341

Browse files
committed
Implement a quasi-static scheduler.
1 parent dc71953 commit c811341

File tree

8 files changed

+561
-1
lines changed

8 files changed

+561
-1
lines changed

core/reactor_common.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ parse_rti_code_t parse_rti_addr(const char* rti_addr);
175175
void set_federation_id(const char* fid);
176176
#endif
177177

178+
#ifdef SCHEDULER_QS
179+
/**
180+
* Path to the static schedule text file (specified on the command line)
181+
*/
182+
char* static_schedule_path = NULL;
183+
#endif
184+
178185
/**
179186
* Allocate memory using calloc (so the allocated memory is zeroed out)
180187
* and record the allocated memory on the specified self struct so that
@@ -1618,6 +1625,7 @@ void schedule_output_reactions(reaction_t* reaction, int worker) {
16181625
downstream_reaction->is_STP_violated, downstream_reaction->name);
16191626
}
16201627
#endif
1628+
#ifndef SCHEDULER_QS // Include the optimization (downstream_to_execute_now) if QS scheduler is not in use.
16211629
if (downstream_reaction != NULL && downstream_reaction != downstream_to_execute_now) {
16221630
num_downstream_reactions++;
16231631
// If there is exactly one downstream reaction that is enabled by this
@@ -1646,11 +1654,16 @@ void schedule_output_reactions(reaction_t* reaction, int worker) {
16461654
_lf_trigger_reaction(downstream_reaction, worker);
16471655
}
16481656
}
1657+
#else // If QS scheduler is used, exclude the optimization so that it does not affect quasi-static scheduling.
1658+
// Queue the reaction.
1659+
_lf_trigger_reaction(downstream_reaction, worker);
1660+
#endif // SCHEDULER_QS
16491661
}
16501662
}
16511663
}
16521664
}
16531665
}
1666+
#ifndef SCHEDULER_QS // Exclude the optimization so that it does not affect quasi-static scheduling.
16541667
if (downstream_to_execute_now != NULL) {
16551668
LF_PRINT_LOG("Worker %d: Optimizing and executing downstream reaction now: %s", worker, downstream_to_execute_now->name);
16561669
bool violation = false;
@@ -1730,6 +1743,7 @@ void schedule_output_reactions(reaction_t* reaction, int worker) {
17301743
LF_PRINT_DEBUG("Finally, reset reaction's is_STP_violated field to false: %s",
17311744
downstream_to_execute_now->name);
17321745
}
1746+
#endif // SCHEDULER_QS
17331747
}
17341748

17351749
/**
@@ -1797,6 +1811,10 @@ void usage(int argc, const char* argv[]) {
17971811
printf(" -r, --rti <n>\n");
17981812
printf(" The address of the RTI, which can be in the form of user@host:port or ip:port.\n\n");
17991813
#endif
1814+
#ifdef SCHEDULER_QS
1815+
printf(" -s, --static-schedule <n>\n");
1816+
printf(" The path to the static schedule text file.\n\n");
1817+
#endif
18001818

18011819
printf("Command given:\n");
18021820
for (int i = 0; i < argc; i++) {
@@ -1946,7 +1964,12 @@ int process_args(int argc, const char* argv[]) {
19461964
return 0;
19471965
}
19481966
}
1949-
#endif
1967+
#endif
1968+
#ifdef SCHEDULER_QS
1969+
else if (strcmp(arg, "-s") == 0 || strcmp(arg, "--static-schedule") == 0) {
1970+
static_schedule_path = argv[i++];
1971+
}
1972+
#endif
19501973
else if (strcmp(arg, "--ros-args") == 0) {
19511974
// FIXME: Ignore ROS arguments for now
19521975
} else {

core/threaded/scheduler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6767
typedef struct {
6868
size_t* num_reactions_per_level;
6969
size_t num_reactions_per_level_size;
70+
reaction_t** reaction_instances;
7071
} sched_params_t;
7172

7273
/**

0 commit comments

Comments
 (0)