[cpp-threads] memory model

Doug Lea dl at cs.oswego.edu
Thu Apr 28 14:25:32 BST 2005


Sorry to be argumentative, but this needs arguing:

Peter:

> 
> We all know that the average programmer will just sprinkle the code 
> liberally with "volatile" qualifiers until it appears correct and doesn't 
> crash.

As opposed to sprinkling liberally with locks until it appears
correct and doesn't happen to deadlock with sample inputs?

Or as opposed to not doing anything because you can't figure out
what to do?

> 
> The result will be neither correct nor efficient.

Ditto.

Alexander:

> As for msync, atomic<>
> (and perhaps atomic_pair<>) with explicit unidirectional constraints
> on competing operations plus a few bidirectional msync::{*}fence() 
> functions is the way to go, I believe.
> 
> http://www.google.de/groups?selm=4157CFA9.31445113%40web.de
> 


Can you show what common usages like double-check and ready-flags
would look like under this proposal? And compare with using volatile?

-Doug




More information about the cpp-threads mailing list