summaryrefslogtreecommitdiff
path: root/lib/libpthread/pthread_misc.c
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2007-11-13 17:20:08 +0000
committerad <ad@NetBSD.org>2007-11-13 17:20:08 +0000
commit66ac2ffaf293a1766211e270fcce0ba856f8f80e (patch)
tree14c1c20985051c159c5d7b74ce133f33a8efdd64 /lib/libpthread/pthread_misc.c
parent3c776c8aa6570d9365bd4dc5468590e6c51103bb (diff)
Mutexes:
- Play scrooge again and chop more cycles off acquire/release. - Spin while the lock holder is running on another CPU (adaptive mutexes). - Do non-atomic release. Threadreg: - Add the necessary hooks to use a thread register. - Add the code for i386, using %gs. - Leave i386 code disabled until xen and COMPAT_NETBSD32 have the changes.
Diffstat (limited to 'lib/libpthread/pthread_misc.c')
-rw-r--r--lib/libpthread/pthread_misc.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/libpthread/pthread_misc.c b/lib/libpthread/pthread_misc.c
index 62089aa7664..47b01eaeb07 100644
--- a/lib/libpthread/pthread_misc.c
+++ b/lib/libpthread/pthread_misc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_misc.c,v 1.2 2007/08/16 13:54:17 ad Exp $ */
+/* $NetBSD: pthread_misc.c,v 1.3 2007/11/13 17:20:09 ad Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_misc.c,v 1.2 2007/08/16 13:54:17 ad Exp $");
+__RCSID("$NetBSD: pthread_misc.c,v 1.3 2007/11/13 17:20:09 ad Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@@ -49,13 +49,16 @@ __RCSID("$NetBSD: pthread_misc.c,v 1.2 2007/08/16 13:54:17 ad Exp $");
#include "pthread.h"
#include "pthread_int.h"
+int pthread__sched_yield(void);
+
int _sys___sigprocmask14(int, const sigset_t *, sigset_t *);
int _sys_nanosleep(const struct timespec *, struct timespec *);
+int _sys_sched_yield(void);
__strong_alias(_nanosleep, nanosleep)
__strong_alias(__libc_thr_sigsetmask,pthread_sigmask)
__strong_alias(__sigprocmask14,pthread_sigmask)
-__strong_alias(__libc_thr_yield,_sys_sched_yield)
+__strong_alias(__libc_thr_yield,pthread__sched_yield)
/*ARGSUSED*/
int
@@ -109,3 +112,22 @@ nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
*/
return _sys_nanosleep(rqtp, rmtp);
}
+
+int
+pthread__sched_yield(void)
+{
+ pthread_t self;
+ int error;
+
+ self = pthread__self();
+
+#ifdef PTHREAD__HAVE_ATOMIC
+ /* Memory barrier for unlocked mutex release. */
+ pthread__membar_producer();
+#endif
+ self->pt_blocking++;
+ error = _sys_sched_yield();
+ self->pt_blocking--;
+
+ return error;
+}