This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Fw: [patch] Make std::tr1::shared_ptr thread-safe.
- From: Alexander Terekhov <alexander dot terekhov at gmail dot com>
- To: Peter Dimov <pdimov at mmltd dot net>
- Cc: Paolo Carlini <pcarlini at suse dot de>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, libstdc++ at gcc dot gnu dot org, Jonathan Wakely <cow at compsoc dot man dot ac dot uk>
- Date: Thu, 31 Mar 2005 17:45:46 +0200
- Subject: Re: Fw: [patch] Make std::tr1::shared_ptr thread-safe.
- References: <OF24DE43AB.98214558-ONC1256FD5.0044D61E-C1256FD5.0044BD18@de.ibm.com> <e52efbe105033105212ee0988a@mail.gmail.com>
- Reply-to: Alexander Terekhov <alexander dot terekhov at gmail dot com>
Just to clarify. Peter Dimov wrote:
: Apologies for repeating myself, but this is an important point: the empty
: critical sections fix a different problem (memory visibility). The
: compare_and_swap way is not a substitute for them. It eliminates the
: non-empty critical section in add_ref_lock, nothing more.
Right. As for memory visibility, the issue here is that shared_ptr's
"control block" is mutable object. The msync protocol on "self count"
must take care of inter-thread ordering with respect to modifications
(of another "use count", I mean) and destruction of control block.
If it doesn't, then empty critical sections at the right places (on
the same lock) can be used to sorta compensate that.
regards,
alexander.