This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: tr1::shared_ptr and v3's atomic ops



> Since I incorporated shared_ptr into v3 Peter Dimov has modified the
> Boost version so that (on Windows) it doesn't use any locks. I had
> already done something similar for the version I added to v3, except
> that I couldn't make shared_count::add_ref_lock() lock-free, since
> v3's atomic compare_and_swap() was removed some years ago:
> http://gcc.gnu.org/ml/gcc-patches/2001-10/msg00215.html
> 
> I have two questions about this
> 
> 1) could compare_and_swap be resurrected, or is the porting headache too
> much bother?

I think we need this functionality. I'm not quite sure the best way to
go about this. For some time we've been kicking around the idea that
the atomic ops should just be compiler builtins.

Thus, maybe something like:

__builtin_atomic_compare_and_swap
__builtin_atomic_add
__builtin_atomic_exchange_and_add

Jason, Richard: any thought on this? Maybe this isn't the best time to
do this, and v3 should just re-add exchange_and_add to atomicity.h?

> 2) Do the v3 atomic ops give any guarantees about memory synchronisation
> on systems with relaxed memory visibility rules ?  Peter Dimov has asked
> on the Boost list for help regarding v3's atomic ops, as he wants to
> have a lock-free shared_ptr on unix as well as on Windows:
> http://lists.boost.org/MailArchives/boost/msg81481.php

Jason is probably the best person to ask about this.

-benjamin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]