From 674cdbbceedd2e4eea16e5534cfcbdf1bc14de6e Mon Sep 17 00:00:00 2001 From: davidxu Date: Wed, 31 Oct 2007 01:44:50 +0000 Subject: Don't do adaptive spinning if it is running on UP kernel. --- lib/libthr/thread/thr_mutex.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/libthr') 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 #include #include -#include -#include #include #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--) { -- cgit v1.1