From 59ad7697705a65940f6370c28729aff87d446b46 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 10 Jul 2017 21:17:04 +0200 Subject: util/u_queue: add an option to resize the queue when it's full MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consider the following situation: mtx_lock(mutex); do_something(); util_queue_add_job(...); mtx_unlock(mutex); If the queue is full, util_queue_add_job will wait for a free slot. If the job which is currently being executed tries to lock the mutex, it will be stuck forever, because util_queue_add_job is stuck. The deadlock can be trivially resolved by increasing the queue size (reallocating the queue) in util_queue_add_job if the queue is full. Then util_queue_add_job becomes wait-free. radeonsi will use it. Reviewed-by: Nicolai Hähnle --- src/util/u_queue.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/util/u_queue.h') diff --git a/src/util/u_queue.h b/src/util/u_queue.h index edd6babb5c7..ff713ae54d6 100644 --- a/src/util/u_queue.h +++ b/src/util/u_queue.h @@ -43,6 +43,7 @@ extern "C" { #endif #define UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY (1 << 0) +#define UTIL_QUEUE_INIT_RESIZE_IF_FULL (1 << 1) /* Job completion fence. * Put this into your job structure. @@ -69,6 +70,7 @@ struct util_queue { cnd_t has_queued_cond; cnd_t has_space_cond; thrd_t *threads; + unsigned flags; int num_queued; unsigned num_threads; int kill_threads; -- cgit v1.2.3