[cpp-threads] C++ memory model

Peter Dimov pdimov at mmltd.net
Wed Sep 23 00:30:34 BST 2009


Boehm, Hans wrote:

> I don't object if those of you more experienced with standardese
> agree.  I'd be concerned about making this normative without a
> definition of a "reasonable amount of time", and that could be
> tricky.  I assumed that was the reasonfor the "should".

"Should" means that the implementation should do something unless it has 
good reasons to not do so.

"Shall within a reasonable amount of time" -> the store must become visible 
after a (second|minute|hour|day|year|century)

"Should within a reasonable amount of time" -> the store may never become 
visible if the implementation decides that propagating it would be too hard

> With a nonpreemptive scheduler, we have to deal with the fact that
>
> atomic<int> x(0);
>
> Thread 1:
> x = 1;
>
> Thread 2:
> while (!x);
>
> may not terminate, even if the load of x stays in the loop.

I think that we don't guarantee forward progress anywhere, and generally 
pretend that non-preemptive schedulers and thread priorities don't exist?

29.3/9 only demands that the store be eventually made visible to a thread 
that executes a load. Scheduling issues may prevent the observer thread from 
ever reaching the load, but does this invalidate or weaken 29.3/9 in any 
way?




More information about the cpp-threads mailing list