diff options
| author | ad <ad@NetBSD.org> | 2006-12-23 05:14:46 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2006-12-23 05:14:46 +0000 |
| commit | 1ac6a89b79760f25efddd665a4dca817272bbfaf (patch) | |
| tree | 16b3f488e238ae2691b2080b7336c138b83ee1b7 /lib/libpthread/pthread_lock.c | |
| parent | 642cea631210394ce02896c04a12450c9ca8825e (diff) | |
Conditionalised support for 1:1 threads. Needs associated kernel changes
and more work to be useful.
Diffstat (limited to 'lib/libpthread/pthread_lock.c')
| -rw-r--r-- | lib/libpthread/pthread_lock.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/libpthread/pthread_lock.c b/lib/libpthread/pthread_lock.c index c532c10cf65..0705c717855 100644 --- a/lib/libpthread/pthread_lock.c +++ b/lib/libpthread/pthread_lock.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_lock.c,v 1.14 2005/03/17 17:23:21 jwise Exp $ */ +/* $NetBSD: pthread_lock.c,v 1.15 2006/12/23 05:14:47 ad Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread_lock.c,v 1.14 2005/03/17 17:23:21 jwise Exp $"); +__RCSID("$NetBSD: pthread_lock.c,v 1.15 2006/12/23 05:14:47 ad Exp $"); #include <sys/types.h> #include <sys/lock.h> @@ -190,11 +190,16 @@ pthread_spinlock(pthread_t thread, pthread_spin_t *lock) * (in case (a), we should let the code finish and * we will bail out in pthread_spinunlock()). */ +#ifdef PTHREAD_SA if (thread->pt_next != NULL) { PTHREADD_ADD(PTHREADD_SPINPREEMPT); pthread__assert(thread->pt_blockgen == thread->pt_unblockgen); pthread__switch(thread, thread->pt_next); } +#else + /* XXXLWP */ + sched_yield(); +#endif /* try again */ count = nspins; SDPRINTF(("(pthread_spinlock %p) incrementing spinlock from %d\n", @@ -217,7 +222,8 @@ pthread_spintrylock(pthread_t thread, pthread_spin_t *lock) ++thread->pt_spinlocks; ret = pthread__simple_lock_try(lock); - + +#ifdef PTHREAD_SA if (ret == 0) { SDPRINTF(("(pthread_spintrylock %p) decrementing spinlock from %d\n", thread, thread->pt_spinlocks)); @@ -229,6 +235,7 @@ pthread_spintrylock(pthread_t thread, pthread_spin_t *lock) pthread__switch(thread, thread->pt_next); } } +#endif return ret; } @@ -247,6 +254,7 @@ pthread_spinunlock(pthread_t thread, pthread_spin_t *lock) #endif PTHREADD_ADD(PTHREADD_SPINUNLOCKS); +#ifdef PTHREAD_SA /* * If we were preempted while holding a spinlock, the * scheduler will notice this and continue us. To be good @@ -260,6 +268,7 @@ pthread_spinunlock(pthread_t thread, pthread_spin_t *lock) /* pthread__assert(thread->pt_blockgen == thread->pt_unblockgen); */ pthread__switch(thread, thread->pt_next); } +#endif } |
