1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-27 16:39:08 +00:00

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
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77059

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) {