[cpp-threads] RE: volatile, memory models, threads

Herb Sutter hsutter at microsoft.com
Wed Mar 1 21:12:25 GMT 2006


Doug wrote:
> Herb Sutter wrote:
> > As someone who hasn't closely followed all the details of the
various
> > proposals and alternatives: Could you summarise the difference
between
> > Java 5 volatile and the current proposal for C++ volatile (assuming
we
> > do reuse that qualifier which seems like a good idea)?
> 
> I don't think we've discussed this is a while, but last I recall,
> C++ volatile would be slightly weaker than Java, in that it could
> map to IA64 ld.acq/st.rel. Although on x86 and sparc would probably
> be implemented the same as Java: Reorder constraints, plus a StoreLoad
> on writes.

And for what examples does this cause issues/limitations? I was curious
about your statement that Java volatile could be used in a case where
the proposed C++ volatile couldn't, which makes me wonder/concerned
about whether we're closing doors we shouldn't close.

So I'd like to understand this, and I'd appreciate it if you or someone
else could show a quick motivating example(s), how the solution to the
example different in the two volatile models, and what (and how ugly)
the workarounds in the C++ volatile model would be. Thanks in advance!

Herb




More information about the cpp-threads mailing list