diff options
author | davidxu <davidxu@FreeBSD.org> | 2012-08-11 23:17:02 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2012-08-11 23:17:02 +0000 |
commit | 72ce06de363df873b583c5e3420f53a5606aa570 (patch) | |
tree | 8501a3ded0069591fa70e408e03c5ebeb279b9b9 /lib/libthr/thread/thr_mutex.c | |
parent | decb55dbb51905dce41fc4ec5f400aafa247556c (diff) | |
download | FreeBSD-src-72ce06de363df873b583c5e3420f53a5606aa570.zip FreeBSD-src-72ce06de363df873b583c5e3420f53a5606aa570.tar.gz |
MFp4:
Further decreases unexpected context switches by defering mutex wakeup
until internal sleep queue lock is released.
Diffstat (limited to 'lib/libthr/thread/thr_mutex.c')
-rw-r--r-- | lib/libthr/thread/thr_mutex.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 91b47ec..61ff077 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -92,7 +92,7 @@ int __pthread_mutex_setyieldloops_np(pthread_mutex_t *mutex, int count); static int mutex_self_trylock(pthread_mutex_t); static int mutex_self_lock(pthread_mutex_t, const struct timespec *abstime); -static int mutex_unlock_common(struct pthread_mutex *, int); +static int mutex_unlock_common(struct pthread_mutex *, int, int *); static int mutex_lock_sleep(struct pthread *, pthread_mutex_t, const struct timespec *); @@ -461,7 +461,7 @@ _pthread_mutex_unlock(pthread_mutex_t *mutex) struct pthread_mutex *mp; mp = *mutex; - return (mutex_unlock_common(mp, 0)); + return (mutex_unlock_common(mp, 0, NULL)); } int @@ -476,7 +476,7 @@ _mutex_cv_lock(struct pthread_mutex *m, int count) } int -_mutex_cv_unlock(struct pthread_mutex *m, int *count) +_mutex_cv_unlock(struct pthread_mutex *m, int *count, int *defer) { /* @@ -484,7 +484,7 @@ _mutex_cv_unlock(struct pthread_mutex *m, int *count) */ *count = m->m_count; m->m_count = 0; - (void)mutex_unlock_common(m, 1); + (void)mutex_unlock_common(m, 1, defer); return (0); } @@ -629,7 +629,7 @@ mutex_self_lock(struct pthread_mutex *m, const struct timespec *abstime) } static int -mutex_unlock_common(struct pthread_mutex *m, int cv) +mutex_unlock_common(struct pthread_mutex *m, int cv, int *mtx_defer) { struct pthread *curthread = _get_curthread(); uint32_t id; @@ -657,12 +657,12 @@ mutex_unlock_common(struct pthread_mutex *m, int cv) defered = 1; m->m_flags &= ~PMUTEX_FLAG_DEFERED; } else - defered = 0; + defered = 0; DEQUEUE_MUTEX(curthread, m); - _thr_umutex_unlock(&m->m_lock, id); + _thr_umutex_unlock2(&m->m_lock, id, mtx_defer); - if (curthread->will_sleep == 0 && defered) { + if (mtx_defer == NULL && defered) { _thr_wake_all(curthread->defer_waiters, curthread->nwaiter_defer); curthread->nwaiter_defer = 0; |