summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2007-10-31 01:50:48 +0000
committerdavidxu <davidxu@FreeBSD.org>2007-10-31 01:50:48 +0000
commitc01b76419281c9304fca99310c5843d4f6f99ee5 (patch)
treeda4457a1ca209349389b1f4f2ad668831bc619da /lib/libthr
parent674cdbbceedd2e4eea16e5534cfcbdf1bc14de6e (diff)
downloadFreeBSD-src-c01b76419281c9304fca99310c5843d4f6f99ee5.zip
FreeBSD-src-c01b76419281c9304fca99310c5843d4f6f99ee5.tar.gz
Avoid doing adaptive spinning for priority protected mutex, current
implementation always does lock in kernel.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_mutex.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index b54d70e..a1f2734 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -366,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 (m->m_lock.m_flags & UMUTEX_PRIO_PROTECT)
+ goto sleep_in_kernel;
+
if (!_thr_is_smp)
goto yield_loop;
@@ -381,8 +384,7 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *mutex,
if (ret == 0)
goto done;
} else {
- if (_thr_spinloops != 0 &&
- !(m->m_lock.m_flags & UMUTEX_PRIO_PROTECT)) {
+ if (_thr_spinloops != 0) {
count = _thr_spinloops;
while (count) {
if (m->m_lock.m_owner == UMUTEX_UNOWNED) {
@@ -407,6 +409,7 @@ yield_loop:
}
}
+sleep_in_kernel:
if (abstime == NULL) {
ret = __thr_umutex_lock(&m->m_lock);
} else if (__predict_false(
OpenPOWER on IntegriCloud