diff options
| author | cl <cl@NetBSD.org> | 2003-11-24 23:54:13 +0000 |
|---|---|---|
| committer | cl <cl@NetBSD.org> | 2003-11-24 23:54:13 +0000 |
| commit | 774b4b225bbb9c8647e0b8cf3b87d71ee51ef7a3 (patch) | |
| tree | c2d0bcca27fd8b845b5fe0eef060cd52e67a4953 /lib/libpthread | |
| parent | 2d72f7258362aa6c5653fc27ad34a5906e1defa5 (diff) | |
Update mutex/rwlock/sem code to match recent change in cond code.
Diffstat (limited to 'lib/libpthread')
| -rw-r--r-- | lib/libpthread/pthread_cond.c | 13 | ||||
| -rw-r--r-- | lib/libpthread/pthread_mutex.c | 12 | ||||
| -rw-r--r-- | lib/libpthread/pthread_rwlock.c | 8 | ||||
| -rw-r--r-- | lib/libpthread/sem.c | 13 |
4 files changed, 21 insertions, 25 deletions
diff --git a/lib/libpthread/pthread_cond.c b/lib/libpthread/pthread_cond.c index 6cd5dc9022a..196a63f1fa1 100644 --- a/lib/libpthread/pthread_cond.c +++ b/lib/libpthread/pthread_cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_cond.c,v 1.13 2003/11/24 22:54:31 nathanw Exp $ */ +/* $NetBSD: pthread_cond.c,v 1.14 2003/11/24 23:54:13 cl Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread_cond.c,v 1.13 2003/11/24 22:54:31 nathanw Exp $"); +__RCSID("$NetBSD: pthread_cond.c,v 1.14 2003/11/24 23:54:13 cl Exp $"); #include <errno.h> #include <sys/time.h> @@ -292,16 +292,15 @@ pthread_cond_signal(pthread_cond_t *cond) self = pthread__self(); pthread_spinlock(self, &cond->ptc_lock); signaled = PTQ_FIRST(&cond->ptc_waiters); - if (signaled != NULL) + if (signaled != NULL) { PTQ_REMOVE(&cond->ptc_waiters, signaled, pt_sleep); + pthread__sched(self, signaled); + PTHREADD_ADD(PTHREADD_COND_WOKEUP); + } #ifdef ERRORCHECK if (PTQ_EMPTY(&cond->ptc_waiters)) cond->ptc_mutex = NULL; #endif - if (signaled != NULL) { - pthread__sched(self, signaled); - PTHREADD_ADD(PTHREADD_COND_WOKEUP); - } pthread_spinunlock(self, &cond->ptc_lock); } diff --git a/lib/libpthread/pthread_mutex.c b/lib/libpthread/pthread_mutex.c index 68170c995dd..20ad4068902 100644 --- a/lib/libpthread/pthread_mutex.c +++ b/lib/libpthread/pthread_mutex.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_mutex.c,v 1.16 2003/05/27 15:22:56 christos Exp $ */ +/* $NetBSD: pthread_mutex.c,v 1.17 2003/11/24 23:54:13 cl Exp $ */ /*- * Copyright (c) 2001, 2003 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread_mutex.c,v 1.16 2003/05/27 15:22:56 christos Exp $"); +__RCSID("$NetBSD: pthread_mutex.c,v 1.17 2003/11/24 23:54:13 cl Exp $"); #include <errno.h> #include <limits.h> @@ -360,15 +360,13 @@ pthread_mutex_unlock(pthread_mutex_t *mutex) self = pthread__self(); pthread_spinlock(self, &mutex->ptm_interlock); blocked = PTQ_FIRST(&mutex->ptm_blocked); - if (blocked) - PTQ_REMOVE(&mutex->ptm_blocked, blocked, pt_sleep); - pthread_spinunlock(self, &mutex->ptm_interlock); - - /* Give the head of the blocked queue another try. */ if (blocked) { + PTQ_REMOVE(&mutex->ptm_blocked, blocked, pt_sleep); PTHREADD_ADD(PTHREADD_MUTEX_UNLOCK_UNBLOCK); + /* Give the head of the blocked queue another try. */ pthread__sched(self, blocked); } + pthread_spinunlock(self, &mutex->ptm_interlock); } return 0; } diff --git a/lib/libpthread/pthread_rwlock.c b/lib/libpthread/pthread_rwlock.c index b2943d94ef5..4d3a565a007 100644 --- a/lib/libpthread/pthread_rwlock.c +++ b/lib/libpthread/pthread_rwlock.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_rwlock.c,v 1.5 2003/03/08 08:03:35 lukem Exp $ */ +/* $NetBSD: pthread_rwlock.c,v 1.6 2003/11/24 23:54:13 cl Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread_rwlock.c,v 1.5 2003/03/08 08:03:35 lukem Exp $"); +__RCSID("$NetBSD: pthread_rwlock.c,v 1.6 2003/11/24 23:54:13 cl Exp $"); #include <errno.h> @@ -417,13 +417,13 @@ pthread_rwlock_unlock(pthread_rwlock_t *rwlock) } } - pthread_spinunlock(self, &rwlock->ptr_interlock); - if (writer != NULL) pthread__sched(self, writer); else pthread__sched_sleepers(self, &blockedq); + pthread_spinunlock(self, &rwlock->ptr_interlock); + return 0; } diff --git a/lib/libpthread/sem.c b/lib/libpthread/sem.c index 7bdfca6edd4..c028371fb43 100644 --- a/lib/libpthread/sem.c +++ b/lib/libpthread/sem.c @@ -1,4 +1,4 @@ -/* $NetBSD: sem.c,v 1.6 2003/03/08 08:03:36 lukem Exp $ */ +/* $NetBSD: sem.c,v 1.7 2003/11/24 23:54:13 cl Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: sem.c,v 1.6 2003/03/08 08:03:36 lukem Exp $"); +__RCSID("$NetBSD: sem.c,v 1.7 2003/11/24 23:54:13 cl Exp $"); #include <sys/types.h> #include <sys/ksem.h> @@ -387,13 +387,12 @@ sem_post(sem_t *sem) pthread_spinlock(self, &(*sem)->usem_interlock); (*sem)->usem_count++; blocked = PTQ_FIRST(&(*sem)->usem_waiters); - if (blocked) + if (blocked) { PTQ_REMOVE(&(*sem)->usem_waiters, blocked, pt_sleep); - pthread_spinunlock(self, &(*sem)->usem_interlock); - - /* Give the head of the blocked queue another try. */ - if (blocked) + /* Give the head of the blocked queue another try. */ pthread__sched(self, blocked); + } + pthread_spinunlock(self, &(*sem)->usem_interlock); return (0); } |
