|
Boost : |
From: Chris Thomasson (cristom_at_[hidden])
Date: 2006-10-24 11:10:59
"Anthony Williams" <anthony_w.geo_at_[hidden]> wrote in message
news:y7r53mxs.fsf_at_yahoo.com...
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
>> Chris Thomasson wrote:
>>> Here is the initial experimental pseudo-code that I am thinking about
>>> prototyping in IA-32 Assembly:
>>>
>>> http://groups.google.com/group/comp.programming.threads/browse_frm/thread/5ffb0ed46a4bcb4b
>>
>> Seems like it can work. Don't you only need one bit for writes though?
>
> It's essentially the same algorithm I've used in my latest offering on the
> thread_rewrite branch.
>
> http://boost.cvs.sourceforge.net/boost/boost/boost/thread/win32/read_write_mutex.hpp?revision=1.1.2.8&view=markup&pathrev=thread_rewrite
>
> I use 3 bits for the actual state (1 bit for currently shared, 1 for
> currently
> exclusive, and 1 for shared with upgradable), a 14 bit count of waiting
> writers, and a 15 bit count of waiting/running readers, so it all fits in
> a
> 32-bit word, and I can use plain CAS rather than DWCAS. I've also extended
> the
> algorithm to cover upgradeable locks.
I only make use of DWCAS on 32-bit systems; CAS is 100% compatible with my
algorithm on 64-bit systems... BTW, is yours starvation-free?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk