Use pthread__sched_sleepers() instead of iterating over sleep queues
ourself.
This commit is contained in:
parent
029982e17b
commit
96b5a26db2
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue