Clarification: Acquiring a mutex when a read/write lock is held
Mateusz Guzik
mjguzik at gmail.com
Tue Apr 21 11:39:20 UTC 2015
On Tue, Apr 21, 2015 at 04:33:24PM +0530, Dheeraj Kandula wrote:
> Hey All,
> Can you clarify the following
>
> I have a read write lock locked. Next I want to acquire a mutex when the
> read write lock is held. Is this allowed or not. As far as I can understand
> from the "FreeBSD Kernel Developers Handbook" this operation is allowed in
> FreeBSD9.0, 10.0 and further.
>
> But the read write lock cannot be held while sleeping. Doesn't this
> contradict the above statement, as a thread will go to sleep if can't
> acquire the mutex when another thread holds the mutex.
>
> Hence what sleep are we referring here. Is this sleep(unbounded sleep) or
> the bounded sleep.
>
Both lock types allow bound sleep, so there is nothing preventing you
from establishing the order either way.
Of course then there is the quesiton whether these particular locks you
have in mind can be taken in the order you want to take them.
--
Mateusz Guzik <mjguzik gmail.com>
More information about the freebsd-hackers
mailing list