More on memory barriers

Benjamin Kosnik bkoz@redhat.com
Wed Sep 15 18:47:00 GMT 2004


>Hmm?  Why do we need the read barrier on the initialization path?  I would
>expect the mutex to provide enough of a read barrier.

Yes, this is something that I don't understand either. RTH tried to
explain this to me a bit ago but I confess I didn't get it, but some of
that might have been due to the confusion between atomic locking and
mutex locking in that discussion.

Maybe Richard could try that explanation again?

I would have thought that the Double Checked Lock would be written much
like the code you posted Jason. This idiom is appearing more and more
often in libstdc++  (currently sans the mb parts!) so I would very much
like to achieve consensus on the right way to do this.

-benjamin



More information about the Gcc mailing list