diff options
author | davidxu <davidxu@FreeBSD.org> | 2007-10-31 01:44:50 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2007-10-31 01:44:50 +0000 |
commit | 674cdbbceedd2e4eea16e5534cfcbdf1bc14de6e (patch) | |
tree | 00469cda6753b19e4793bfda698fb7f9ce5f3a0f /lib/libthr/thread | |
parent | e199852bb6031e319928eaef8c89defbf5b596ca (diff) | |
download | FreeBSD-src-674cdbbceedd2e4eea16e5534cfcbdf1bc14de6e.zip FreeBSD-src-674cdbbceedd2e4eea16e5534cfcbdf1bc14de6e.tar.gz |
Don't do adaptive spinning if it is running on UP kernel.
Diffstat (limited to 'lib/libthr/thread')
-rw-r--r-- | lib/libthr/thread/thr_mutex.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 0b8a8cc..b54d70e 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -39,8 +39,6 @@ #include <string.h> #include <sys/param.h> #include <sys/queue.h> -#include <machine/cpu.h> -#include <machine/cpufunc.h> #include <pthread.h> #include "un-namespace.h" @@ -368,6 +366,9 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *mutex, * the lock is likely to be released quickly and it is * faster than entering the kernel */ + if (!_thr_is_smp) + goto yield_loop; + if (m->m_type == PTHREAD_MUTEX_ADAPTIVE_NP) { count = MUTEX_ADAPTIVE_SPINS; @@ -380,7 +381,7 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *mutex, if (ret == 0) goto done; } else { - if (_thr_spinloops != 0 && _thr_is_smp && + if (_thr_spinloops != 0 && !(m->m_lock.m_flags & UMUTEX_PRIO_PROTECT)) { count = _thr_spinloops; while (count) { @@ -395,6 +396,7 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *mutex, } } +yield_loop: if (_thr_yieldloops != 0) { count = _thr_yieldloops; while (count--) { |