From 3b929638685f938f636995a9a06202126ca27b2d Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 7 Apr 2022 17:25:27 -0400 Subject: [PATCH] refactor: priority_queue_grow_nolock --- runtime/include/priority_queue.h | 5 ++++- runtime/src/local_runqueue_minheap.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/runtime/include/priority_queue.h b/runtime/include/priority_queue.h index 79aa992..01d3d17 100644 --- a/runtime/include/priority_queue.h +++ b/runtime/include/priority_queue.h @@ -288,11 +288,14 @@ priority_queue_initialize(size_t capacity, bool use_lock, priority_queue_get_pri /** * Double capacity of priority queue + * Note: currently there is no equivalent call for PQs that are not thread-local and need to be locked because it is + * unclear if the fact that the lock is a member in the struct that might be moved by realloc breaks the guarantees of + * the lock. * @param priority_queue to resize * @returns pointer to PR. This may have been moved by realloc! */ static inline struct priority_queue * -priority_queue_grow(struct priority_queue *priority_queue) +priority_queue_grow_nolock(struct priority_queue *priority_queue) { assert(priority_queue != NULL); diff --git a/runtime/src/local_runqueue_minheap.c b/runtime/src/local_runqueue_minheap.c index 6db81f7..b75bbc9 100644 --- a/runtime/src/local_runqueue_minheap.c +++ b/runtime/src/local_runqueue_minheap.c @@ -37,7 +37,7 @@ local_runqueue_minheap_add(struct sandbox *sandbox) { int return_code = priority_queue_enqueue_nolock(local_runqueue_minheap, sandbox); if (unlikely(return_code == -ENOSPC)) { - local_runqueue_minheap = priority_queue_grow(local_runqueue_minheap); + local_runqueue_minheap = priority_queue_grow_nolock(local_runqueue_minheap); return_code = priority_queue_enqueue_nolock(local_runqueue_minheap, sandbox); if (unlikely(return_code == -ENOSPC)) panic("Thread Runqueue is full!\n"); }