feat: Expose scheduler as runtime config

main
Sean McBride 4 years ago
parent 76b5346339
commit c0a97a5394

@ -95,3 +95,22 @@ runtime_is_worker()
return false;
}
enum RUNTIME_SCHEDULER
{
RUNTIME_SCHEDULER_FIFO = 0,
RUNTIME_SCHEDULER_EDF = 1
};
static inline char *
print_runtime_scheduler(enum RUNTIME_SCHEDULER variant)
{
switch (variant) {
case RUNTIME_SCHEDULER_FIFO:
return "RUNTIME_SCHEDULER_FIFO";
case RUNTIME_SCHEDULER_EDF:
return "RUNTIME_SCHEDULER_EDF";
}
};
extern enum RUNTIME_SCHEDULER runtime_scheduler;

@ -28,6 +28,7 @@ uint32_t runtime_first_worker_processor = 0;
int runtime_worker_threads_argument[WORKER_THREAD_CORE_COUNT] = { 0 }; /* The worker sets its argument to -1 on error */
pthread_t runtime_worker_threads[WORKER_THREAD_CORE_COUNT];
enum RUNTIME_SCHEDULER runtime_scheduler = RUNTIME_SCHEDULER_FIFO;
/**
* Returns instructions on use of CLI if used incorrectly
@ -183,6 +184,22 @@ runtime_start_runtime_worker_threads()
exit(-1);
}
void
runtime_configure()
{
/* Scheduler Policy */
char *scheduler_policy = getenv("SLEDGE_SCHEDULER");
if (scheduler_policy == NULL) scheduler_policy = "FIFO";
if (strcmp(scheduler_policy, "EDF") == 0) {
runtime_scheduler = RUNTIME_SCHEDULER_EDF;
} else if (strcmp(scheduler_policy, "FIFO") == 0) {
runtime_scheduler = RUNTIME_SCHEDULER_FIFO;
} else {
panic("Invalid scheduler policy: %s. Must be {EDF|FIFO}\n", scheduler_policy);
}
}
int
main(int argc, char **argv)
{
@ -209,12 +226,14 @@ main(int argc, char **argv)
runtime_set_resource_limits_to_max();
runtime_allocate_available_cores();
runtime_configure();
runtime_initialize();
#ifdef LOG_MODULE_LOADING
debuglog("Parsing modules file [%s]\n", argv[1]);
#endif
if (module_new_from_json(argv[1])) panic("failed to parse modules file[%s]\n", argv[1]);
debuglog("Scheduler Policy: %s\n", print_runtime_scheduler(runtime_scheduler));
debuglog("Starting listener thread\n");
listener_thread_initialize();
debuglog("Starting worker threads\n");

@ -122,8 +122,17 @@ runtime_initialize(void)
/* Allocate and Initialize the global deque
TODO: Improve to expose variant as a config #Issue 93
*/
// global_request_scheduler_deque_initialize();
global_request_scheduler_minheap_initialize();
switch (runtime_scheduler) {
case RUNTIME_SCHEDULER_EDF:
global_request_scheduler_minheap_initialize();
break;
case RUNTIME_SCHEDULER_FIFO:
global_request_scheduler_deque_initialize();
break;
default:
panic("Invalid scheduler policy set: %u\n", runtime_scheduler);
}
/* Mask Signals */
software_interrupt_mask_signal(SIGUSR1);

@ -344,8 +344,16 @@ worker_thread_main(void *return_code)
arch_context_init(&worker_thread_base_context, 0, 0);
/* Initialize Runqueue Variant */
// local_runqueue_list_initialize();
local_runqueue_minheap_initialize();
switch (runtime_scheduler) {
case RUNTIME_SCHEDULER_EDF:
local_runqueue_minheap_initialize();
break;
case RUNTIME_SCHEDULER_FIFO:
local_runqueue_list_initialize();
break;
default:
panic("Invalid scheduler policy set: %u\n", runtime_scheduler);
}
/* Initialize Completion Queue */
local_completion_queue_initialize();

Loading…
Cancel
Save