Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost][interprocess] upgradable_mutex is semi-recursive...
From: Lars Hagström (lars_at_[hidden])
Date: 2009-01-23 06:15:18


Hi,

>> Something that explains this could be useful in the interprocess
>> documentation.
>
> I don't mention anywhere that upgradable lock is recursive, so this is
> not going to work if you use it that way.

The difference with interprocess_mutex not being recursive and
upgradable_mutex not being recursive is that if you try to lock
interprocess_mutex recursively you will get a deadlock *every time*,
whereas locking the upgradable_mutex recursively (lock_shareable) will
work *most* of the time.
This is the reason I think that this might be worth a mention in the
docs. It took me a fair while to work out that this was what caused me
some rare deadlocks, and having a mention in the docs may help others.

> I really would like to implement option 1 or 2, but I still don't see an
> easy solution. Sorry!

Yes, that was what I was afraid of. I had a look at the code, but didn't
really have time/patience to delve deeply into it. I was hoping that
there was some easy way of doing this that was beyond my understanding
of the implementation. I thought of changing the internal mutex into a
recursive_mutex, but I couldn't easily work out what would happen if I
did that...

Anyway, if there is no easy way to "fix" this, I will stick with making
sure that I don't lock recursively... Which is obviously the correct
solution with the current behaviour.

Lars


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net