Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpthread Update mutex/rwlock/sem code to match recent ...
details: https://anonhg.NetBSD.org/src/rev/611862119dc2
branches: trunk
changeset: 555681:611862119dc2
user: cl <cl%NetBSD.org@localhost>
date: Mon Nov 24 23:54:13 2003 +0000
description:
Update mutex/rwlock/sem code to match recent change in cond code.
diffstat:
lib/libpthread/pthread_cond.c | 13 ++++++-------
lib/libpthread/pthread_mutex.c | 12 +++++-------
lib/libpthread/pthread_rwlock.c | 8 ++++----
lib/libpthread/sem.c | 13 ++++++-------
4 files changed, 21 insertions(+), 25 deletions(-)
diffs (147 lines):
diff -r 395a7ea24cf2 -r 611862119dc2 lib/libpthread/pthread_cond.c
--- a/lib/libpthread/pthread_cond.c Mon Nov 24 23:48:47 2003 +0000
+++ b/lib/libpthread/pthread_cond.c Mon Nov 24 23:54:13 2003 +0000
@@ -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 @@
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 -r 395a7ea24cf2 -r 611862119dc2 lib/libpthread/pthread_mutex.c
--- a/lib/libpthread/pthread_mutex.c Mon Nov 24 23:48:47 2003 +0000
+++ b/lib/libpthread/pthread_mutex.c Mon Nov 24 23:54:13 2003 +0000
@@ -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 @@
self = pthread__self();
pthread_spinlock(self, &mutex->ptm_interlock);
blocked = PTQ_FIRST(&mutex->ptm_blocked);
- if (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) {
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 -r 395a7ea24cf2 -r 611862119dc2 lib/libpthread/pthread_rwlock.c
--- a/lib/libpthread/pthread_rwlock.c Mon Nov 24 23:48:47 2003 +0000
+++ b/lib/libpthread/pthread_rwlock.c Mon Nov 24 23:54:13 2003 +0000
@@ -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_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 -r 395a7ea24cf2 -r 611862119dc2 lib/libpthread/sem.c
--- a/lib/libpthread/sem.c Mon Nov 24 23:48:47 2003 +0000
+++ b/lib/libpthread/sem.c Mon Nov 24 23:54:13 2003 +0000
@@ -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,14 +387,13 @@
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);
+ /* Give the head of the blocked queue another try. */
+ pthread__sched(self, blocked);
+ }
pthread_spinunlock(self, &(*sem)->usem_interlock);
- /* Give the head of the blocked queue another try. */
- if (blocked)
- pthread__sched(self, blocked);
-
return (0);
}
Home |
Main Index |
Thread Index |
Old Index