diff --git a/runtime/include/perf_window.h b/runtime/include/perf_window.h index 5e7b5d5..c79c57a 100644 --- a/runtime/include/perf_window.h +++ b/runtime/include/perf_window.h @@ -144,7 +144,10 @@ perf_window_get_percentile(struct perf_window *self, int percentile, int precomp assert(self != NULL); assert(percentile >= 50 && percentile <= 99); int size = self->count; - assert(size > 0); + //assert(size > 0); + if (size == 0) { + return 0; + } if (likely(size >= PERF_WINDOW_BUFFER_SIZE)) return self->by_duration[precomputed_index].execution_time; diff --git a/runtime/include/sandbox_functions.h b/runtime/include/sandbox_functions.h index 03e8ba9..3803cc2 100644 --- a/runtime/include/sandbox_functions.h +++ b/runtime/include/sandbox_functions.h @@ -105,12 +105,12 @@ sandbox_get_priority(void *element) return sandbox->absolute_deadline; }; -static inline uint64_t +static inline int64_t sandbox_get_srsf_priority(void *element) { struct sandbox *sandbox = (struct sandbox *)element; uint64_t now = __getcycles(); - uint64_t remaining_slack = sandbox->remaining_slack - (now - sandbox->last_update_timestamp); + int64_t remaining_slack = sandbox->remaining_slack - (now - sandbox->last_update_timestamp); return remaining_slack; }; @@ -230,9 +230,9 @@ sandbox_mem_print_perf(struct sandbox *sandbox) uint32_t delayed_us = (sandbox->completion_timestamp - sandbox->absolute_deadline) / runtime_processor_speed_MHz; if (miss_deadline) { - mem_log("%lu miss deadline, delayed %u us, actual cost %u\n", sandbox->id, delayed_us, total_time); + mem_log("%lu miss deadline, delayed %u us, actual cost %u module name %s\n", sandbox->id, delayed_us, total_time, sandbox->module->name); } else { - mem_log("%lu meet deadline\n", sandbox->id); + mem_log("%lu meet deadline, module name %s\n", sandbox->id, sandbox->module->name); } } diff --git a/runtime/include/scheduler.h b/runtime/include/scheduler.h index 4ec2a10..af94fd2 100644 --- a/runtime/include/scheduler.h +++ b/runtime/include/scheduler.h @@ -3,7 +3,9 @@ #include #include #include +#include +#include "memlogging.h" #include "client_socket.h" #include "current_sandbox.h" #include "global_request_scheduler.h" @@ -30,6 +32,7 @@ enum SCHEDULER }; extern enum SCHEDULER scheduler; +extern _Atomic uint32_t scheduling_counter; static inline struct sandbox * scheduler_edf_get_next() @@ -181,6 +184,11 @@ scheduler_runqueue_initialize() } } +static inline void +scheduling_counter_increment() +{ + atomic_fetch_add(&scheduling_counter, 1); +} /** * Called by the SIGALRM handler after a quantum * Assumes the caller validates that there is something to preempt @@ -204,6 +212,8 @@ scheduler_preempt(ucontext_t *user_context) /* If current equals next, no switch is necessary, so resume execution */ if (current == next) return; + scheduling_counter_increment(); + mem_log("scheduling count is %u\n", scheduling_counter); #ifdef LOG_PREEMPTION debuglog("Preempting sandbox %lu to run sandbox %lu\n", current->id, next->id); #endif diff --git a/runtime/src/admissions_info.c b/runtime/src/admissions_info.c index 519de35..7174f1a 100644 --- a/runtime/src/admissions_info.c +++ b/runtime/src/admissions_info.c @@ -12,19 +12,18 @@ void admissions_info_initialize(struct admissions_info *self, char* module_name, int percentile, uint64_t expected_execution, uint64_t relative_deadline) { + assert(self != NULL); perf_window_initialize(&self->perf_window, module_name); + if (unlikely(percentile < 50 || percentile > 99)) panic("Invalid admissions percentile"); + self->percentile = percentile; + self->control_index = PERF_WINDOW_BUFFER_SIZE * percentile / 100; #ifdef ADMISSIONS_CONTROL assert(relative_deadline > 0); assert(expected_execution > 0); self->relative_deadline = relative_deadline; self->estimate = admissions_control_calculate_estimate(expected_execution, relative_deadline); debuglog("Initial Estimate: %lu\n", self->estimate); - assert(self != NULL); - if (unlikely(percentile < 50 || percentile > 99)) panic("Invalid admissions percentile"); - self->percentile = percentile; - - self->control_index = PERF_WINDOW_BUFFER_SIZE * percentile / 100; #ifdef LOG_ADMISSIONS_CONTROL debuglog("Percentile: %d\n", self->percentile); debuglog("Control Index: %d\n", self->control_index); diff --git a/runtime/src/global_request_scheduler_minheap.c b/runtime/src/global_request_scheduler_minheap.c index 1ab1a21..94f45d8 100644 --- a/runtime/src/global_request_scheduler_minheap.c +++ b/runtime/src/global_request_scheduler_minheap.c @@ -71,12 +71,12 @@ sandbox_request_get_priority_fn(void *element) return sandbox_request->absolute_deadline; }; -uint64_t +int64_t sandbox_request_get_priority_srsf_fn(void *element) { struct sandbox_request *sandbox_request = (struct sandbox_request *)element; uint64_t now = __getcycles(); - uint64_t remaining_slack = sandbox_request->remaining_slack - (now - sandbox_request->last_update_timestamp); + int64_t remaining_slack = sandbox_request->remaining_slack - (now - sandbox_request->last_update_timestamp); return remaining_slack; }; diff --git a/runtime/src/scheduler.c b/runtime/src/scheduler.c index e6c67b1..b119f0b 100644 --- a/runtime/src/scheduler.c +++ b/runtime/src/scheduler.c @@ -1,3 +1,4 @@ #include "scheduler.h" enum SCHEDULER scheduler = SCHEDULER_EDF; +_Atomic uint32_t scheduling_counter = 0;