chore: local_runqueue add cleanup

main
Sean McBride 4 years ago
parent 5ccf8bbd87
commit d36b28bf21

@ -5,7 +5,7 @@
#include "sandbox.h" #include "sandbox.h"
/* Returns pointer back if successful, null otherwise */ /* Returns pointer back if successful, null otherwise */
typedef struct sandbox *(*local_runqueue_add_fn_t)(struct sandbox *); typedef void (*local_runqueue_add_fn_t)(struct sandbox *);
typedef bool (*local_runqueue_is_empty_fn_t)(void); typedef bool (*local_runqueue_is_empty_fn_t)(void);
typedef void (*local_runqueue_delete_fn_t)(struct sandbox *sandbox); typedef void (*local_runqueue_delete_fn_t)(struct sandbox *sandbox);
typedef struct sandbox *(*local_runqueue_get_next_fn_t)(); typedef struct sandbox *(*local_runqueue_get_next_fn_t)();
@ -22,7 +22,7 @@ struct local_runqueue_config {
void local_runqueue_initialize(struct local_runqueue_config *config); void local_runqueue_initialize(struct local_runqueue_config *config);
/* This is currently only used by worker_thread_wakeup_sandbox */ /* This is currently only used by worker_thread_wakeup_sandbox */
struct sandbox *local_runqueue_add(struct sandbox *); void local_runqueue_add(struct sandbox *);
void local_runqueue_delete(struct sandbox *); void local_runqueue_delete(struct sandbox *);
bool local_runqueue_is_empty(); bool local_runqueue_is_empty();
struct sandbox *local_runqueue_get_next(); struct sandbox *local_runqueue_get_next();

@ -11,5 +11,5 @@ panic(const char *format, ...)
va_start(args, format); va_start(args, format);
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
exit(EXIT_FAILURE); assert(0);
} }

@ -12,9 +12,8 @@ local_runqueue_initialize(struct local_runqueue_config *config)
/** /**
* Adds a sandbox request to the run queue * Adds a sandbox request to the run queue
* @param sandbox to add * @param sandbox to add
* @returns sandbox that was added (or NULL?)
*/ */
struct sandbox * void
local_runqueue_add(struct sandbox *sandbox) local_runqueue_add(struct sandbox *sandbox)
{ {
assert(local_runqueue.add_fn != NULL); assert(local_runqueue.add_fn != NULL);

@ -68,14 +68,13 @@ local_runqueue_list_get_next()
* Append a sandbox to the runqueue * Append a sandbox to the runqueue
* @returns the appended sandbox * @returns the appended sandbox
*/ */
struct sandbox * void
local_runqueue_list_append(struct sandbox *sandbox_to_append) local_runqueue_list_append(struct sandbox *sandbox_to_append)
{ {
assert(ps_list_singleton_d(sandbox_to_append)); assert(ps_list_singleton_d(sandbox_to_append));
// fprintf(stderr, "(%d,%lu) %s: run %p, %s\n", sched_getcpu(), pthread_self(), __func__, s, // fprintf(stderr, "(%d,%lu) %s: run %p, %s\n", sched_getcpu(), pthread_self(), __func__, s,
// s->module->name); // s->module->name);
ps_list_head_append_d(&local_runqueue_list, sandbox_to_append); ps_list_head_append_d(&local_runqueue_list, sandbox_to_append);
return sandbox_to_append;
} }
/** /**

@ -25,25 +25,18 @@ local_runqueue_minheap_is_empty()
/** /**
* Adds a sandbox to the run queue * Adds a sandbox to the run queue
* @param sandbox * @param sandbox
* @returns pointer to request if added. NULL otherwise * @returns pointer to sandbox added
*/ */
static struct sandbox * void
local_runqueue_minheap_add(struct sandbox *sandbox) local_runqueue_minheap_add(struct sandbox *sandbox)
{ {
int original_length = priority_queue_length(&local_runqueue_minheap); int original_length = priority_queue_length(&local_runqueue_minheap);
int return_code = priority_queue_enqueue(&local_runqueue_minheap, sandbox, "Runqueue"); int return_code = priority_queue_enqueue(&local_runqueue_minheap, sandbox, "Runqueue");
if (return_code == -1) { if (return_code == -1) panic("Thread Runqueue is full!\n");
printf("Thread Runqueue is full!\n");
exit(EXIT_FAILURE);
}
int final_length = priority_queue_length(&local_runqueue_minheap); /* Assumption: Should always take lock because thread-local runqueue */
assert(return_code != -2);
assert(final_length == original_length + 1);
assert(return_code == 0);
return sandbox;
} }
/** /**

Loading…
Cancel
Save