Update mutex/rwlock/sem code to match recent change in cond code.
This commit is contained in:
parent
2d72f72583
commit
774b4b225b
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue