From 7fb923cd35ebae674d74e0f57abaff367f89441f Mon Sep 17 00:00:00 2001 From: Bora Sahin Date: Mon, 16 Nov 2009 19:06:45 +0200 Subject: [PATCH] A workaround for an unmatched locker-unlocker mutex problem. If sleepers on a mutex were more than one, only one of them was woken up. This caused the other ones to sleep forever. Now, there is not any facility to check if there are still sleepers on the kernel space when a thread is about to unlock a mutex. To workaround this problem, we started waking up all the threads instead of one. This brings another problem called thundering herd but also provides random fairness which gives more oppurtunity to a higher priority thread to get the lock. --- src/api/mutex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/mutex.c b/src/api/mutex.c index d17fed3..829d190 100644 --- a/src/api/mutex.c +++ b/src/api/mutex.c @@ -210,7 +210,7 @@ int mutex_control_unlock(struct mutex_queue_head *mqhead, * now wake all of them up in FIFO order. * FIXME: Make sure this is FIFO order. It doesn't seem so. */ - wake_up(&mutex_queue->wqh_contenders, WAKEUP_ASYNC); + wake_up_all(&mutex_queue->wqh_contenders, WAKEUP_ASYNC); /* Since noone is left, delete the mutex queue */ mutex_control_remove(mqhead, mutex_queue);