diff options
Diffstat (limited to 'lib/libpthread/pthread_misc.c')
| -rw-r--r-- | lib/libpthread/pthread_misc.c | 28 |
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; +} |
