From ffc19644c071b7e9ec1fe21d95c8d12ea0f47d93 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Fri, 18 May 2001 00:36:05 +0000 Subject: Condition variable waiters are queued in descending priority order, so there is no need to wake all waiters to assure that the highest priority thread is run. As the semaphore code is written, there was no correctness problem, but the change improves sem_post() performance. Pointed out by: deischen --- lib/libpthread/thread/thr_sem.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'lib/libpthread') diff --git a/lib/libpthread/thread/thr_sem.c b/lib/libpthread/thread/thr_sem.c index 9ed6922d38f2..851eca293ae6 100644 --- a/lib/libpthread/thread/thr_sem.c +++ b/lib/libpthread/thread/thr_sem.c @@ -226,15 +226,8 @@ _sem_post(sem_t *sem) pthread_mutex_lock(&(*sem)->lock); (*sem)->count++; - if ((*sem)->nwaiters > 0) { - /* - * We must use pthread_cond_broadcast() rather than - * pthread_cond_signal() in order to assure that the highest - * priority thread is run by the scheduler, since - * pthread_cond_signal() signals waiting threads in FIFO order. - */ - pthread_cond_broadcast(&(*sem)->gtzero); - } + if ((*sem)->nwaiters > 0) + pthread_cond_signal(&(*sem)->gtzero); pthread_mutex_unlock(&(*sem)->lock); -- cgit v1.3