Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Apr 2007 17:09:18 -0500 (CDT)
From:      Sergey Babkin <babkin@verizon.net>
To:        Julian Elischer <julian@elischer.org>, Hans Petter Selasky <hselasky@c2i.net>
Cc:        Attilio Rao <attilio@freebsd.org>, freebsd-hackers@freebsd.org
Subject:   Re: Re: msleep() on recursivly locked mutexes
Message-ID:  <2782784.9021177711758431.JavaMail.root@vms073.mailsrvcs.net>

next in thread | raw e-mail | index | archive | help
>From: Julian Elischer <julian@elischer.org>
>Basically you shouldn't have a recursed mutex FULL STOP. We have a couple 
>of instances in the kernel where we allow a mutex to recurse, but they had to be 
>hard fought, and the general rule is "Don't". If you are recursing on 
>a mutex you need to switch to some other method of doing things.
>e.g. reference counts, turnstiles, whatever.. use the mutex to create these 

One typical problem is when someone holds a mutex
and needs to call a function that also tried to get the mutex.
The typical solution for it is to provide two versions of
this function, one expecting the mutex being already held
by the caller, the other being a wrapper that grabs the mutex and
then calls the actual worker function.

-SB





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2782784.9021177711758431.JavaMail.root>