Subj : Re: Memory Barriers, Compiler Optimizations, etc. To : comp.programming.threads From : Joseph Seigh Date : Sat Feb 05 2005 11:33 am On Sat, 5 Feb 2005 02:22:51 +0200, Ziv Caspi wrote: > Microsoft has already provided some guarantees here, as specified in > http://www.microsoft.com/whdc/driver/kernel/MP_issues.mspx. In particular, > it treats volatile reads as having acquire semantics, and volatile writes as > having release semantics, so if you target CL 14 (or later), you have a > solution. I've not hears of other C/C++ compilers that provide similar > guarantees, which probably is more a testament to my ignorance than anything > else :-) Strictly speaking, acquire and release aren't accurate characterizations Volatiles are totally ordered with respect to other volatiles separated by sequence points And only at the compiler generated code level. > > Note that the guarantees we currently provide hold only for the platforms > Windows and CL run on -- x86, x64, and Itanium. We currently don't provide a > guaranteed "future-proof" model for future platforms, although some of us > would really like us to do so... The semantics of volatile are implemenation dependent, so Microsoft can implement volatile with those semantics. However, Microsoft should make it explicitly clear that those are guarantees only provided by Microsoft's C/C++ compiler and not by the C/C++ standard or necessarily any other compiler. In other words, such behavior may be non-portable. It's considered good form to document non-standard behavior. As far as future proofing, I though Microsoft was pushing for CLR to go into C somehow. -- Joe Seigh .