Date: Thu, 26 Apr 2007 21:36:33 +0200 From: Hans Petter Selasky <hselasky@c2i.net> To: freebsd-hackers@freebsd.org Subject: msleep() on recursivly locked mutexes Message-ID: <200704262136.33196.hselasky@c2i.net>
index | next in thread | raw e-mail
Hi,
In the new USB stack I have defined the following:
u_int32_t
mtx_drop_recurse(struct mtx *mtx)
{
u_int32_t recurse_level = mtx->mtx_recurse;
u_int32_t recurse_curr = recurse_level;
mtx_assert(mtx, MA_OWNED);
while(recurse_curr--) {
mtx_unlock(mtx);
}
return recurse_level;
}
void
mtx_pickup_recurse(struct mtx *mtx, u_int32_t recurse_level)
{
mtx_assert(mtx, MA_OWNED);
while(recurse_level--) {
mtx_lock(mtx);
}
return;
}
When I do a msleep() I do it like this:
level = mtx_drop_recurse(ctd->p_mtx);
error = msleep(ctd, ctd->p_mtx, 0,
"config td sleep", timeout);
mtx_pickup_recurse(ctd->p_mtx, level);
Are there any comments on integrating this functionality into msleep(), and
adding mtx_drop_recurse() and mtx_pickup_recurse() to the FreeBSD kernel?
--HPS
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704262136.33196.hselasky>
