[cpp-threads] Web site updated

Peter Dimov pdimov at mmltd.net
Tue Feb 13 03:47:14 GMT 2007


Paul E. McKenney wrote:

> From the load_raw() side, my hope would be that the compiler would be
> required to "forget" where the value came from, thus being unable to
> recognize that the following:
>
> x = a.load_raw();
> y = a.load_raw();
>
> might be cached -- in other words, there must be a separate load from
> "a" for both x and y.  Or am I missing your point?

The compiler is allowed to optimize out the second load since there is no 
way of enforcing a particular execution, one where something other-thread-ly 
happens between the two statements. The execution where the current thread 
is not interrupted between the two loads is legitimate, so the programmer 
has no grounds to complain if he gets a program that does exactly that.

A compiler is not, however, allowed to move the load_raw outside a loop if 
this can turn a finite loop into an infinite one (this would violate the 
"eventually"). But it's probably allowed to move it outside a loop that is 
executed a "small" number of times. And probably not allowed to move it 
outside a loop executed 10^8 times (if we say that in addition to 
"eventually", a store needs to become visible to a load_raw in a "reasonably 
short period"). 




More information about the cpp-threads mailing list