chore: replace spinloop with return to main loop

main
Sean McBride 4 years ago
parent 01d32c19f8
commit 9749299672

@ -82,21 +82,9 @@ local_runqueue_minheap_get_next()
struct sandbox_request *sandbox_request = NULL; struct sandbox_request *sandbox_request = NULL;
int sandbox_rc = priority_queue_top(&local_runqueue_minheap, (void **)&sandbox); int sandbox_rc = priority_queue_top(&local_runqueue_minheap, (void **)&sandbox);
if (sandbox_rc == -ENOENT) { if (sandbox_rc == -ENOENT && global_request_scheduler_peek() < ULONG_MAX) {
/* local runqueue empty, try to pull a sandbox request */ /* local runqueue empty, try to pull a sandbox request */
if (global_request_scheduler_remove(&sandbox_request) < 0) goto done;
/*
* This is effectively the idle loop. A worker thread spinlocks on
* the earliest deadline, checking for the condition that indicates that
* it is empty.
*/
while (sandbox_request == NULL) {
/* Spin without taking the lock if the request queue is empty */
while (global_request_scheduler_peek() == ULONG_MAX)
;
if (global_request_scheduler_remove(&sandbox_request) < 0) goto done;
}
/* Try to allocate a sandbox, returning the request on failure */ /* Try to allocate a sandbox, returning the request on failure */
sandbox = sandbox_allocate(sandbox_request); sandbox = sandbox_allocate(sandbox_request);

Loading…
Cancel
Save