diff options
author | jhb <jhb@FreeBSD.org> | 2001-04-17 03:34:52 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-04-17 03:34:52 +0000 |
commit | 444804685366d0ba28d4365a9e6df0a05b1d377f (patch) | |
tree | dc2457ab7f4f947a48f77775e4b625091368b40a /sys/kern | |
parent | 2f7121276922798f28a0004b0b66e4064afaf00c (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/kern/kern_mutex.c | 3 | ||||
-rw-r--r-- | sys/kern/subr_turnstile.c | 3 |
2 files changed, 6 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; diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index 379b357..6db0e8d 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.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; |