diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pthread_mutex_unlock.c | 9 |
2 files changed, 12 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2004-10-21 Ross Johnson <rpj at callisto.canberra.edu.au>
+ + * pthread_mutex_unlock.c (pthread_mutex_unlock): Must use PulseEvent() + rather than SetEvent() to reset the event if there are no waiters. + 2004-10-19 Ross Johnson <rpj at callisto.canberra.edu.au>
* sem_init.c (sem_init): New semaphore model based on the same idea diff --git a/pthread_mutex_unlock.c b/pthread_mutex_unlock.c index e28b38a..9b8e504 100644 --- a/pthread_mutex_unlock.c +++ b/pthread_mutex_unlock.c @@ -67,8 +67,13 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { if (idx < 0) { - /* Someone may be waiting on that mutex */ - if (SetEvent (mx->event) == 0) + /* + * Someone may be waiting on that mutex. + * Pulse event on an auto-reset event will + * release one waiter if possible, otherwise + * it will just reset the event. + */ + if (PulseEvent (mx->event) == 0) { result = EINVAL; } |