[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Bug in mutex_owned() ?
Hans Petter Selasky <hselasky%c2i.net@localhost> wrote:
> > It can test that current CPU holds the lock, but it wont buy you anything,
> > because if your context (thus CPU) is not holding the lock, then such test
> > is useless - lock state is free to change (e.g. other CPUs can release or
> > acquire your lock at the same time).
> The test is in-fact useful for more than assertions. Like when implementing
> statements to avoid recursive locking. I disagree that it is purely bad
> design that leads one to require mutex_owned() checks.
How are you using it?
"Avoiding" should mean "not requiring". If mutex_owned() is used to avoid
locking of already held lock, then you are basically implementing the idea
of recursive mutex, just in a higher layer. In other words, using of such
checks to make locking decisions have pretty much the same negative effects
of recursive locking.
Main Index |
Thread Index |