diff options
| author | nathanw <nathanw@NetBSD.org> | 2003-01-31 04:59:40 +0000 |
|---|---|---|
| committer | nathanw <nathanw@NetBSD.org> | 2003-01-31 04:59:40 +0000 |
| commit | 96b5a26db24acb3345f0cc9f3686bcff463293d8 (patch) | |
| tree | 028d436166ef3323c5233026d81407c65ce42f4c /lib/libpthread | |
| parent | 029982e17b26eb443d521f951b41bdb7cc0199dd (diff) | |
Use pthread__sched_sleepers() instead of iterating over sleep queues
ourself.
Diffstat (limited to 'lib/libpthread')
| -rw-r--r-- | lib/libpthread/pthread.c | 15 | ||||
| -rw-r--r-- | lib/libpthread/pthread_barrier.c | 6 | ||||
| -rw-r--r-- | lib/libpthread/pthread_cond.c | 10 | ||||
| -rw-r--r-- | lib/libpthread/pthread_rwlock.c | 7 |
4 files changed, 16 insertions, 22 deletions
diff --git a/lib/libpthread/pthread.c b/lib/libpthread/pthread.c index 55afb854410..feea672d2aa 100644 --- a/lib/libpthread/pthread.c +++ b/lib/libpthread/pthread.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.7 2003/01/29 14:03:08 drochner Exp $ */ +/* $NetBSD: pthread.c,v 1.8 2003/01/31 04:59:40 nathanw Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -345,7 +345,7 @@ pthread__idle(void) void pthread_exit(void *retval) { - pthread_t self, joiner; + pthread_t self; struct pt_clean_t *cleanup; int nt; @@ -397,11 +397,11 @@ pthread_exit(void *retval) /* Whoah, we're the last one. Time to go. */ exit(0); } - /* Wake up all the potential joiners. Only one can win. + /* + * Wake up all the potential joiners. Only one can win. * (Can you say "Thundering Herd"? I knew you could.) */ - PTQ_FOREACH(joiner, &self->pt_joiners, pt_sleep) - pthread__sched(self, joiner); + pthread__sched_sleepers(self, &self->pt_joiners); pthread__block(self, &self->pt_join_lock); } @@ -505,7 +505,7 @@ pthread_equal(pthread_t t1, pthread_t t2) int pthread_detach(pthread_t thread) { - pthread_t self, joiner; + pthread_t self; self = pthread__self(); @@ -525,8 +525,7 @@ pthread_detach(pthread_t thread) thread->pt_flags |= PT_FLAG_DETACHED; /* Any joiners have to be punted now. */ - PTQ_FOREACH(joiner, &thread->pt_joiners, pt_sleep) - pthread__sched(self, joiner); + pthread__sched_sleepers(self, &thread->pt_joiners); pthread_spinunlock(self, &thread->pt_join_lock); diff --git a/lib/libpthread/pthread_barrier.c b/lib/libpthread/pthread_barrier.c index 78704b09341..422d01703ad 100644 --- a/lib/libpthread/pthread_barrier.c +++ b/lib/libpthread/pthread_barrier.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_barrier.c,v 1.3 2003/01/25 00:47:06 nathanw Exp $ */ +/* $NetBSD: pthread_barrier.c,v 1.4 2003/01/31 04:59:40 nathanw Exp $ */ /*- * Copyright (c) 2001, 2003 The NetBSD Foundation, Inc. @@ -163,7 +163,6 @@ pthread_barrier_wait(pthread_barrier_t *barrier) */ if (barrier->ptb_curcount + 1 == barrier->ptb_initcount) { struct pthread_queue_t blockedq; - pthread_t signaled; SDPRINTF(("(barrier wait %p) Satisfied %p\n", self, barrier)); @@ -173,8 +172,7 @@ pthread_barrier_wait(pthread_barrier_t *barrier) barrier->ptb_curcount = 0; barrier->ptb_generation++; - PTQ_FOREACH(signaled, &blockedq, pt_sleep) - pthread__sched(self, signaled); + pthread__sched_sleepers(self, &blockedq); pthread_spinunlock(self, &barrier->ptb_lock); diff --git a/lib/libpthread/pthread_cond.c b/lib/libpthread/pthread_cond.c index be083e82930..52352bb3288 100644 --- a/lib/libpthread/pthread_cond.c +++ b/lib/libpthread/pthread_cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_cond.c,v 1.4 2003/01/31 04:26:50 nathanw Exp $ */ +/* $NetBSD: pthread_cond.c,v 1.5 2003/01/31 04:59:40 nathanw Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -226,7 +226,6 @@ pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, pthread_mutex_lock(mutex); pthread__testcancel(self); - return retval; } @@ -280,9 +279,9 @@ pthread_cond_signal(pthread_cond_t *cond) if (PTQ_EMPTY(&cond->ptc_waiters)) cond->ptc_mutex = NULL; #endif + pthread_spinunlock(self, &cond->ptc_lock); if (signaled != NULL) pthread__sched(self, signaled); - pthread_spinunlock(self, &cond->ptc_lock); } return 0; @@ -292,7 +291,7 @@ pthread_cond_signal(pthread_cond_t *cond) int pthread_cond_broadcast(pthread_cond_t *cond) { - pthread_t self, signaled; + pthread_t self; struct pthread_queue_t blockedq; #ifdef ERRORCHECK if ((cond == NULL) || (cond->ptc_magic != _PT_COND_MAGIC)) @@ -311,9 +310,8 @@ pthread_cond_broadcast(pthread_cond_t *cond) #ifdef ERRORCHECK cond->ptc_mutex = NULL; #endif - PTQ_FOREACH(signaled, &blockedq, pt_sleep) - pthread__sched(self, signaled); pthread_spinunlock(self, &cond->ptc_lock); + pthread__sched_sleepers(self, &blockedq); } return 0; diff --git a/lib/libpthread/pthread_rwlock.c b/lib/libpthread/pthread_rwlock.c index 2911583b798..bcf363c0121 100644 --- a/lib/libpthread/pthread_rwlock.c +++ b/lib/libpthread/pthread_rwlock.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_rwlock.c,v 1.2 2003/01/18 10:34:16 thorpej Exp $ */ +/* $NetBSD: pthread_rwlock.c,v 1.3 2003/01/31 04:59:40 nathanw Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -378,7 +378,7 @@ pthread_rwlock__callback(void *arg) int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) { - pthread_t self, reader, writer; + pthread_t self, writer; struct pthread_queue_t blockedq; #ifdef ERRORCHECK if ((rwlock == NULL) || (rwlock->ptr_magic != _PT_RWLOCK_MAGIC)) @@ -421,8 +421,7 @@ pthread_rwlock_unlock(pthread_rwlock_t *rwlock) if (writer != NULL) pthread__sched(self, writer); else - PTQ_FOREACH(reader, &blockedq, pt_sleep) - pthread__sched(self, reader); + pthread__sched_sleepers(self, &blockedq); return 0; } |
