Boost logo

Boost :

Subject: Re: [boost] [fiber] new version in vault
From: Helge Bahmann (hcb_at_[hidden])
Date: 2009-11-30 09:41:10


On Mon, 30 Nov 2009, Vicente Botet Escriba wrote:

> Stefan Strasser-2 wrote:
>> namespace sync{
>>
>> template<class Suspend>
>> struct basic_cas_mutex{
>> void lock(){
>> while(true){
>> uint32_t expected = 0;
>> if ( detail::atomic_compare_exchange_strong( & state_, & expected,
>> 1) )

unless you use correct memory ordering constraints, your mutex will be
twice as expensive as a platform-native mutex on any non-x86

[snip]

> Hi,
>
> I like your sync::basic_cas_mutex class template, how it can be used on a
> thread or fiber context or even to build a spin lock. Anyway you will have
> two classes fiber::mutex and thread::mutex with a common implementation. Can
> sync::basic_cas_mutex be used to protect inter-process concurrent access?

why would you ever want to use a mutex that does not properly inform the
system scheduler until when the calling thread should be suspended (in
case of contention) for "true" inter-thread (or even inter-process)
coordination?

Regards,
Helge


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