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: Fw: [patch] Make std::tr1::shared_ptr thread-safe.


On Apr 2, 2005 10:23 PM, Alexander Terekhov
<alexander.terekhov@gmail.com> wrote:
> On Apr 2, 2005 9:43 PM, Paolo Carlini <pcarlini@suse.de> wrote:
> [...]
> > Therefore, I think we can safely say that Jonathan patch is OK, or at
> > least not worse, from the MT point of view than the rest of the library
> 
> Both are broken. Because your current __exchange_and_add() doesn't
> provide suffiecent msync semantics for basic thread-safety of refcounting
> immutable objects.
> 
> Pirate (sink and hoist) talk aside for a moment, in Sparc RMO terms,
> it needs
> 
>  membar load-store
>  <compound atomic load-modify-store>
>  membar store-store
> 
> to "preserve" the order of preceding loads and subsequent stores
> with respect to "dumb" (no value dependent msync) refcount
> decrement.

A sketch of value dependent msync for refcount decrements (under 
basic thread-safety scheme for both immutable and mutable objects
including client provided "deleters") on upcoming XBOX can be found 
here:

http://lists.boost.org/boost/2005/04/23867.php
(all increments can be naked -- no "memory" clobber or any msync 
instructions or labels)

"Memory" clobber for decrements is needed unless compiler is smart 
enough to recognize the presence of msync instructions and will 
behave accordingly with respect to caching/reordering across these 
routines.

regards,
alexander.


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