[cpp-threads] Yet another visibility question

Peter Dimov pdimov at mmltd.net
Thu Dec 21 01:06:56 GMT 2006


Boehm, Hans wrote:

>> The refcounting example doesn't have this problem; the
>> actions that are taken when the count drops to zero are
>> provably dependent since the result of the atomic is not
>> available to other portions of the code and can't cancel the
>> dependence.

> That's not completely clear to me.  If one of the zero refcount
> actions is to clear a field in the object, and that same field
> happens to be cleared in the other case, could the compiler combine
> them and move them up to before the decrement?

But there is no other case. The non-zero action is always a no-op. The only 
problem is whether a subsequent portion of the code can somehow make another 
store dependent on exactly the opposite condition without having access to 
'r1'.

>> All this seems more trouble than it's worth. :-)

> Does that mean that you agree we should forget about dependency-based
> ordering and I should get back to figuring out how to prohibit just
> "out of thin air" results?

My concern was just to not get the worst of both worlds; a prohibition of 
out of thin air results that is effectively a dependency-based ordering but 
can't be exploited by the programmer as such. I'm not even convinced that we 
need to prohibit out of thin air results at all in C++. 




More information about the cpp-threads mailing list