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.
This commit is contained in:
John Baldwin 2001-04-17 03:34:52 +00:00
parent 70825609cf
commit 7141f2ad46
2 changed files with 6 additions and 0 deletions

View File

@ -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;

View File

@ -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;