From dfb1c65e935f29c1aef28b3f63aea5c6993c90c4 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Fri, 3 Jul 2020 19:48:58 -0400 Subject: [PATCH] fix: push PQ error handling to caller --- runtime/include/panic.h | 2 +- runtime/src/local_runqueue_minheap.c | 13 +++++++++---- runtime/src/priority_queue.c | 9 +++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/runtime/include/panic.h b/runtime/include/panic.h index 538f27a..167f632 100644 --- a/runtime/include/panic.h +++ b/runtime/include/panic.h @@ -4,7 +4,7 @@ #include #include -__attribute__((noreturn)) void +__attribute__((noreturn)) static inline void panic(const char *format, ...) { va_list args; diff --git a/runtime/src/local_runqueue_minheap.c b/runtime/src/local_runqueue_minheap.c index 7f4a616..f0e9bc2 100644 --- a/runtime/src/local_runqueue_minheap.c +++ b/runtime/src/local_runqueue_minheap.c @@ -1,10 +1,12 @@ +#include + +#include "current_sandbox.h" +#include "global_request_scheduler.h" #include "local_runqueue.h" #include "local_runqueue_minheap.h" -#include "global_request_scheduler.h" -#include "current_sandbox.h" +#include "panic.h" #include "priority_queue.h" -#include __thread static struct priority_queue local_runqueue_minheap; @@ -63,7 +65,10 @@ local_runqueue_minheap_delete(struct sandbox *sandbox) { assert(sandbox != NULL); int rc = priority_queue_delete(&local_runqueue_minheap, sandbox, "Runqueue"); - assert(rc == 0); + if (rc == -1) { + panic("Err: Thread Local %lu tried to delete sandbox %lu from runqueue, but was not present\n", + pthread_self(), sandbox->start_time); + } } /** diff --git a/runtime/src/priority_queue.c b/runtime/src/priority_queue.c index 6845629..6a3d9c9 100644 --- a/runtime/src/priority_queue.c +++ b/runtime/src/priority_queue.c @@ -181,7 +181,7 @@ priority_queue_enqueue(struct priority_queue *self, void *value, char *name) /** * @param self - the priority queue we want to delete from * @param value - the value we want to delete - * @returns 0 on success. -1 on not found. -2 on unable to take lock + * @returns 0 on success. -1 on not found */ int priority_queue_delete(struct priority_queue *self, void *value, char *name) @@ -198,12 +198,9 @@ priority_queue_delete(struct priority_queue *self, void *value, char *name) did_delete = true; } } + ck_spinlock_fas_unlock(&self->lock); - assert(did_delete); - if (!did_delete) { - printf("[priority_queue_delete] Not found!\n"); - return -1; - }; + if (!did_delete) return -1; return 0; }