[cpp-threads] memory model
Peter Dimov
pdimov at mmltd.net
Fri Apr 29 12:28:18 BST 2005
Peter Dimov wrote:
> Doug Lea wrote:
>> I guess the question here is who we are most afraid of offending:
>>
>> * People who would be unhappy that providing semantics for
>> volatile might sometimes make existing usages more expensive
>>
>> * People who would be unhappy adding another qualifier
>> to mean "accessible by multiple threads without a lock",
>> (that would in most cases have exactly the semantics
>> of volatile).
>>
>> * People who would be unhappy to have to declare every
>> volatile-like variable using atomic templates (which
>> avoids keywords but is programmer-hostile.)
>
> I think that these options do not cover the whole spectrum.
>
> There is also the point of view that [...]
On the other hand, 1.9/6 is clear that the observable behavior of the
abstract machine includes reads and writes to volatile variables. This means
that loads and stores from/to volatile variables must be observed in program
order. If we assume that another thread is a legitimate observer, and I
don't see anything that prohibits this, the standard already says that
volatile obeys sequential consistency. QED. :-)
More information about the cpp-threads
mailing list