handle some unfeasible assert() and negative remaining slack vs the return type of uint64_t of priority function

main
xiaosuGW 3 years ago
parent c57cfe0b20
commit 9ab4001f8d

@ -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;

@ -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);
}
}

@ -3,7 +3,9 @@
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <stdatomic.h>
#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

@ -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);

@ -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;
};

@ -1,3 +1,4 @@
#include "scheduler.h"
enum SCHEDULER scheduler = SCHEDULER_EDF;
_Atomic uint32_t scheduling_counter = 0;

Loading…
Cancel
Save