Boost logo

Boost :

Subject: Re: [boost] Performance characteristics of Boost mutex
From: Philip Bennefall (philip_at_[hidden])
Date: 2014-10-17 16:47:37


On 10/17/2014 10:34 PM, Peter Dimov wrote:
> Philip Bennefall wrote:
>> Hi all,
>>
>> I am detecting some lock contention in my application, and while reading
>> up on this I came across the concept of lightweight mutexes versus
>> supposedly non-lightweight mutexes. I am wondering, can Boosts
>> non-recursive mutex implementation be considered lightweight? In
>> boost/detail I see lightweight_mutex. Should I be using that?
> Probably not.
>
> detail::lightweight_mutex is merely a thin wrapper over CRITICAL_SECTION on
> Windows and pthread_mutex on POSIX. It's "lightweight" only in the sense
> that it doesn't require the user to link against a library (Boost.Thread).
>
> In general, it doesn't make much sense to talk about a "lightweight" mutex
> if you're talking performance. The "weight" of the mutex doesn't - in
> general - have much to do with its performance (nowadays).
>
>
Hi Peter,

I see that Boost thread, since a few years ago from what I can tell, has
its own mutex implementation based on a Windows event where as before it
merely used critical sections. I am curious to know what the reasoning
behind this change was? In short, what are the pros and cons of using
critical sections directly versus the implementation in Boost thread?

Kind regards,

Philip Bennefall


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk