summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2001-05-18 00:36:05 +0000
committerjasone <jasone@FreeBSD.org>2001-05-18 00:36:05 +0000
commit3fbe60fc0d2cac4d9034372eb91fb1a12e58bfc2 (patch)
tree0d4f8d3ac0a4e88f2e63c4bbaf8288bce02e2b39
parent1a6e32f034bde4bab2cd5e6e40cb8cdb3795c1d2 (diff)
downloadFreeBSD-src-3fbe60fc0d2cac4d9034372eb91fb1a12e58bfc2.zip
FreeBSD-src-3fbe60fc0d2cac4d9034372eb91fb1a12e58bfc2.tar.gz
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
-rw-r--r--lib/libc_r/uthread/uthread_sem.c11
-rw-r--r--lib/libkse/thread/thr_sem.c11
-rw-r--r--lib/libpthread/thread/thr_sem.c11
3 files changed, 6 insertions, 27 deletions
diff --git a/lib/libc_r/uthread/uthread_sem.c b/lib/libc_r/uthread/uthread_sem.c
index 9ed6922..851eca2 100644
--- a/lib/libc_r/uthread/uthread_sem.c
+++ b/lib/libc_r/uthread/uthread_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);
diff --git a/lib/libkse/thread/thr_sem.c b/lib/libkse/thread/thr_sem.c
index 9ed6922..851eca2 100644
--- a/lib/libkse/thread/thr_sem.c
+++ b/lib/libkse/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);
diff --git a/lib/libpthread/thread/thr_sem.c b/lib/libpthread/thread/thr_sem.c
index 9ed6922..851eca2 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);
OpenPOWER on IntegriCloud