Boost logo

Boost :

Subject: Re: [boost] wait-free fast-pathed, bounded-time, 100% starvation-free rw-mutex...
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-09-04 11:55:34


"Chris M. Thomasson" <cristom_at_[hidden]> writes:

> "Chris M. Thomasson" <cristom_at_[hidden]> wrote in message
> news:h7ep7q$a5r$1_at_ger.gmane.org...
>> "Chris M. Thomasson" <cristom_at_[hidden]> wrote in message
>> news:h7168i$vq4$1_at_ger.gmane.org...
>>> "Anthony Williams" <anthony.ajw_at_[hidden]> wrote in message
>>> news:87fxbh1ccf.fsf_at_dell.justsoftwaresolutions.co.uk...
>> [...]
>>>> For integration with boost, it would be good if the write-lock member
>>>> functions could be called "lock()" and "unlock()", whilst the read-lock
>>>> member functions are called "lock_shared()" and "unlock_shared()". This
>>>> would allow the existing RAII classes to be used with this new rwmutex
>>>> type.
>>>
>>> Okay. I will add the try lock functions and change the function
>>> names, and re-name the class to `fair_rwmutex' to attempt to get
>>> across that it's `SCHED_OTHER'.
>>
>> Here is some preliminary code which adds some try lock functions,
>> changes the name to `fair_mutex' and renames the
>> wrlock()/wrunlock()' procedures to `lock()/unlock()':
>>
>>
>> http://pastebin.com/f502d0943
>>
>>
>> I still need to test drive the try lock functions in Relacy to see
>> if I missed anything. As for the `SCHED_OTHER' issue, well, I am not
>> sure how to get around that without sacrificing the 100% starvation
>> free and bounded-time guarantees. Humm...
>
> I forgot to destroy a resource in the failure case of the
> constructor. Here is code without the leak:
>
> http://pastebin.com/f527722e0

Thanks. Did you try it in Relacy? It looks OK at a quick glance, but I'm
not sure I haven't missed anything.

Anthony

-- 
Author of C++ Concurrency in Action | http://www.manning.com/williams
just::thread C++0x thread library   | http://www.stdthread.co.uk
Just Software Solutions Ltd         | http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

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