Boost logo

Boost :

Subject: Re: [boost] Performance characteristics of Boost mutex
From: Edward Diener (eldiener_at_[hidden])
Date: 2014-10-17 22:54:09


On 10/17/2014 4: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).

Nonetheless on Windows CRITICAL_SECTION is quite a bit faster than the
mutex object, probably because it is intraprocess whereas Window mutex
objects are interprocess.


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