summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-06-04 21:53:48 +0000
committerjhb <jhb@FreeBSD.org>2002-06-04 21:53:48 +0000
commit408adb728768f69cb8966c1191020d6ea7e66be5 (patch)
tree74dd2af195979cba72051f324486634264a843a6 /sys/kern/kern_mutex.c
parent1ba6786436ce1fc3d10f82452a167a784b696702 (diff)
downloadFreeBSD-src-408adb728768f69cb8966c1191020d6ea7e66be5.zip
FreeBSD-src-408adb728768f69cb8966c1191020d6ea7e66be5.tar.gz
Optimize the adaptive mutex spin a bit. Use a simple while loop with
simple reads (and on IA32, a "pause" instruction for each interation of the loop) to spin until either the mutex owner field changes, or the lock owner stops executing. Suggested by: tanimura Tested on: i386
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index f9b7413..d0fc8c9 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -536,9 +536,12 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
owner = (struct thread *)(v & MTX_FLAGMASK);
if (m != &Giant && thread_runnable(owner)) {
mtx_unlock_spin(&sched_lock);
+ while (mtx_owner(m) == owner &&
+ thread_runnable(owner)) {
#ifdef __i386__
- ia32_pause();
+ ia32_pause();
#endif
+ }
continue;
}
#endif /* SMP && ADAPTIVE_MUTEXES */
OpenPOWER on IntegriCloud