msleep() on recursivly locked mutexes
- From: Hans Petter Selasky <hselasky@xxxxxxx>
- Date: Thu, 26 Apr 2007 21:36:33 +0200
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
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: msleep() on recursivly locked mutexes
- From: John Baldwin
- Re: msleep() on recursivly locked mutexes
- From: Bosko Milekic
- Re: msleep() on recursivly locked mutexes
- From: M. Warner Losh
- Re: msleep() on recursivly locked mutexes
- From: Attilio Rao
- Re: msleep() on recursivly locked mutexes
- From: Julian Elischer
- Re: msleep() on recursivly locked mutexes
- Prev by Date: Re: Usage of kern_* functions in kernel
- Next by Date: Re: msleep() on recursivly locked mutexes
- Previous by thread: Usage of kern_* functions in kernel
- Next by thread: Re: msleep() on recursivly locked mutexes
- Index(es):
Relevant Pages
|