summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-04-17 03:34:52 +0000
committerjhb <jhb@FreeBSD.org>2001-04-17 03:34:52 +0000
commit444804685366d0ba28d4365a9e6df0a05b1d377f (patch)
treedc2457ab7f4f947a48f77775e4b625091368b40a /sys/kern/kern_mutex.c
parent2f7121276922798f28a0004b0b66e4064afaf00c (diff)
downloadFreeBSD-src-444804685366d0ba28d4365a9e6df0a05b1d377f.zip
FreeBSD-src-444804685366d0ba28d4365a9e6df0a05b1d377f.tar.gz
Exit and re-enter the critical section while spinning for a spinlock so
that interrupts can come in while we are waiting for a lock.
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 379b357..6db0e8d 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -431,6 +431,8 @@ _mtx_lock_spin(struct mtx *m, int opts, critical_t mtx_crit, const char *file,
if (_obtain_lock(m, curproc))
break;
+ /* Give interrupts a chance while we spin. */
+ critical_exit(mtx_crit);
while (m->mtx_lock != MTX_UNOWNED) {
if (i++ < 1000000)
continue;
@@ -444,6 +446,7 @@ _mtx_lock_spin(struct mtx *m, int opts, critical_t mtx_crit, const char *file,
panic("spin lock %s held by %p for > 5 seconds",
m->mtx_object.lo_name, (void *)m->mtx_lock);
}
+ mtx_crit = critical_enter();
}
m->mtx_savecrit = mtx_crit;
OpenPOWER on IntegriCloud