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

Doug Lea dl at cs.oswego.edu
Wed Mar 1 19:56:54 GMT 2006


Boehm, Hans wrote:
>> 
> In my view, single-object atomic operations are inherently a low-level
> facility to be used by experts in constructing high performance
> concurrent libraries, which can then be used by merely clever
> programmers in constructing real concurrent applications.
> Unfortunately, I think all of this matters greatly to the resulting
> applications.  Otherwise we shouldn't bother.
> 
> Leaving issues of compatibility and standardese aside, I don't know how
> to construct a useful facility that really does more than that. 
> 

I agree with Hans.

Still, in a perfect world, there would be a way to add a simple
qualifier (especially if that qualifier were named "volatile" :-)
to make common operations by non-expert programmers safe. I was
reminded of this yesterday when reading Bart Smaalders's ACM queue article
http://www.acmqueue.com/modules.php?name=Content&pa=showpage&pid=366
where on the last page, he recommends using plain concurrent reads
on scalars rather than RWLocks or regular locks. In Java, this is fine if such
variables are declared "volatile". The way we are heading here, in C/C++, it is
likely to be OK only if an atomic type, which will entail additional
work and understanding that fewer programmers will get right.

-Doug




More information about the cpp-threads mailing list