summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_mutex.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2006-12-14 13:22:02 +0000
committerdavidxu <davidxu@FreeBSD.org>2006-12-14 13:22:02 +0000
commit26cbb63b3f17779de69c66b42a44cfe79fac3326 (patch)
tree638b9f42bad289d72e784a9d258f1e7e1eee2eb2 /lib/libthr/thread/thr_mutex.c
parent5cd76c6b3834f2ab00f2953bd3d1180427dd8995 (diff)
downloadFreeBSD-src-26cbb63b3f17779de69c66b42a44cfe79fac3326.zip
FreeBSD-src-26cbb63b3f17779de69c66b42a44cfe79fac3326.tar.gz
Create inline function _thr_umutex_trylock2 to only try one atomic
operation, if it is failed, we call syscall directly, this saves one atomic operation per lock contention.
Diffstat (limited to 'lib/libthr/thread/thr_mutex.c')
-rw-r--r--lib/libthr/thread/thr_mutex.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 46e516c..aae27aa 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -343,7 +343,7 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *mutex,
id = TID(curthread);
m = *mutex;
- ret = _thr_umutex_trylock(&m->m_lock, id);
+ ret = _thr_umutex_trylock2(&m->m_lock, id);
if (ret == 0) {
m->m_owner = curthread;
/* Add to the list of owned mutexes: */
@@ -356,7 +356,7 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *mutex,
ret = mutex_self_lock(m, abstime);
} else {
if (abstime == NULL) {
- ret = _thr_umutex_lock(&m->m_lock, id);
+ ret = __thr_umutex_lock(&m->m_lock);
} else if (__predict_false(
abstime->tv_sec < 0 || abstime->tv_nsec < 0 ||
abstime->tv_nsec >= 1000000000)) {
@@ -364,7 +364,7 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *mutex,
} else {
clock_gettime(CLOCK_REALTIME, &ts);
TIMESPEC_SUB(&ts2, abstime, &ts);
- ret = _thr_umutex_timedlock(&m->m_lock, id, &ts2);
+ ret = __thr_umutex_timedlock(&m->m_lock, &ts2);
/*
* Timed out wait is not restarted if
* it was interrupted, not worth to do it.
OpenPOWER on IntegriCloud