chore: validate interrupts disabled at spinlock

main
Sean McBride 4 years ago
parent 8e36412944
commit e898d5ab69

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <pthread.h>
#include <sys/epoll.h> /* for epoll_create1(), epoll_ctl(), struct epoll_event */ #include <sys/epoll.h> /* for epoll_create1(), epoll_ctl(), struct epoll_event */
#include <stdbool.h> #include <stdbool.h>
@ -26,6 +27,10 @@ void stub_init(int32_t offset);
unsigned long long __getcycles(void); unsigned long long __getcycles(void);
/**
* Used to determine if running in the context of a worker thread
* @returns true if worker. false if listener core
*/
static inline bool static inline bool
runtime_is_worker() runtime_is_worker()
{ {

@ -1,6 +1,9 @@
#include <assert.h>
#include "global_request_scheduler.h" #include "global_request_scheduler.h"
#include "panic.h" #include "panic.h"
#include "priority_queue.h" #include "priority_queue.h"
#include "runtime.h"
static struct priority_queue global_request_scheduler_minheap; static struct priority_queue global_request_scheduler_minheap;
@ -12,6 +15,11 @@ static struct priority_queue global_request_scheduler_minheap;
static struct sandbox_request * static struct sandbox_request *
global_request_scheduler_minheap_add(void *sandbox_request) global_request_scheduler_minheap_add(void *sandbox_request)
{ {
/* This function is called by both the listener core and workers */
#ifndef NDEBUG
if (runtime_is_worker()) assert(!software_interrupt_is_enabled());
#endif
int return_code = priority_queue_enqueue(&global_request_scheduler_minheap, sandbox_request); int return_code = priority_queue_enqueue(&global_request_scheduler_minheap, sandbox_request);
/* TODO: Propagate -1 to caller */ /* TODO: Propagate -1 to caller */
if (return_code == -1) panic("Request Queue is full\n"); if (return_code == -1) panic("Request Queue is full\n");
@ -25,6 +33,7 @@ global_request_scheduler_minheap_add(void *sandbox_request)
int int
global_request_scheduler_minheap_remove(struct sandbox_request **removed_sandbox_request) global_request_scheduler_minheap_remove(struct sandbox_request **removed_sandbox_request)
{ {
assert(!software_interrupt_is_enabled());
return priority_queue_dequeue(&global_request_scheduler_minheap, (void **)removed_sandbox_request); return priority_queue_dequeue(&global_request_scheduler_minheap, (void **)removed_sandbox_request);
} }

@ -30,6 +30,8 @@ local_runqueue_minheap_is_empty()
void void
local_runqueue_minheap_add(struct sandbox *sandbox) local_runqueue_minheap_add(struct sandbox *sandbox)
{ {
assert(!software_interrupt_is_enabled());
int return_code = priority_queue_enqueue(&local_runqueue_minheap, sandbox); int return_code = priority_queue_enqueue(&local_runqueue_minheap, sandbox);
/* TODO: propagate RC to caller */ /* TODO: propagate RC to caller */
if (return_code == -1) panic("Thread Runqueue is full!\n"); if (return_code == -1) panic("Thread Runqueue is full!\n");
@ -43,6 +45,8 @@ local_runqueue_minheap_add(struct sandbox *sandbox)
static int static int
local_runqueue_minheap_remove(struct sandbox **to_remove) local_runqueue_minheap_remove(struct sandbox **to_remove)
{ {
assert(!software_interrupt_is_enabled());
return priority_queue_dequeue(&local_runqueue_minheap, (void **)to_remove); return priority_queue_dequeue(&local_runqueue_minheap, (void **)to_remove);
} }
@ -53,7 +57,9 @@ local_runqueue_minheap_remove(struct sandbox **to_remove)
static void static void
local_runqueue_minheap_delete(struct sandbox *sandbox) local_runqueue_minheap_delete(struct sandbox *sandbox)
{ {
assert(!software_interrupt_is_enabled());
assert(sandbox != NULL); assert(sandbox != NULL);
int rc = priority_queue_delete(&local_runqueue_minheap, sandbox); int rc = priority_queue_delete(&local_runqueue_minheap, sandbox);
if (rc == -1) { if (rc == -1) {
panic("Tried to delete sandbox %lu from runqueue, but was not present\n", panic("Tried to delete sandbox %lu from runqueue, but was not present\n",
@ -72,7 +78,6 @@ local_runqueue_minheap_delete(struct sandbox *sandbox)
struct sandbox * struct sandbox *
local_runqueue_minheap_get_next() local_runqueue_minheap_get_next()
{ {
/* Assumption: Software Interrupts are disabed by caller */
assert(!software_interrupt_is_enabled()); assert(!software_interrupt_is_enabled());
struct sandbox * sandbox = NULL; struct sandbox * sandbox = NULL;

@ -1,4 +1,3 @@
#include <pthread.h>
#include <signal.h> #include <signal.h>
#include <sched.h> #include <sched.h>
#include <sys/mman.h> #include <sys/mman.h>

Loading…
Cancel
Save