[cpp-threads] memory model

Peter Dimov pdimov at mmltd.net
Thu Apr 28 14:43:36 BST 2005


Doug Lea wrote:
> 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?

No, as opposed to explicitly tagging accesses with the appropriate ordering 
constraint, as in Alexander's proposal.

MT programming is hard, and lock-free programming is harder. I don't see a 
problem with only providing a set of primitives that appears unfriendly to 
the average programmer. Making it friendly will not really help the average 
programmer write efficient and correct lock-free code.

(This is somewhat similar in spirit to the "locks should not use RAII" 
argument, exceptions aside for a moment.) 





More information about the cpp-threads mailing list