Add in assertions to ensure that we always call msleep or mawait with

either a timeout or a held mutex to detect unprotected infinite sleeps
that can easily lead to deadlock.

Submitted by:	alfred
This commit is contained in:
John Baldwin 2001-05-23 19:38:26 +00:00
parent f73cf22ade
commit b516d2f5e1

View File

@ -383,6 +383,8 @@ msleep(ident, mtx, priority, wmesg, timo)
ktrcsw(p->p_tracep, 1, 0);
#endif
WITNESS_SLEEP(0, &mtx->mtx_object);
KASSERT(timo != 0 || mtx_owned(&Giant) || mtx != NULL,
("sleeping without a mutex"));
mtx_lock_spin(&sched_lock);
if (cold || panicstr) {
/*
@ -574,6 +576,8 @@ mawait(struct mtx *mtx, int priority, int timo)
WITNESS_SAVE_DECL(mtx);
WITNESS_SLEEP(0, &mtx->mtx_object);
KASSERT(timo > 0 || mtx_owned(&Giant) || mtx != NULL,
("sleeping without a mutex"));
mtx_lock_spin(&sched_lock);
DROP_GIANT_NOSWITCH();
if (mtx != NULL) {