[cpp-threads] memory model

Nelson, Clark clark.nelson at intel.com
Wed Apr 27 17:52:33 BST 2005


> I put a very rough draft describing my impression of the 
> current state of
> the memory model proposal at
> 
> http://www.hpl.hp.com/personal/Hans_Boehm/c++mm/mm.html

With respect to the memory model, I've been thinking about the terms of
description that will eventually be used in the standard(s). The key
passage is the "least requirements on a conforming implementation"
(1.9p11). This is the formal statement of the as-if rule, and it also
nails down (if that's the word) the semantics/requirements of volatile.
The definition of "observable behavior" (1.9p6) is clearly relevant,
even though it's not used.

As far as I can tell, eventually some statement very much like the
"least requirements" is going to have to be applied to each thread, and
some definition quite like that of "observable behavior" is going to
have to apply to the ways in which threads can interact.

This is the source of my discomfort with the idea of allowing threads to
interact through non-volatile objects. Today, there are two classes of
side effects: observable/external (to volatile objects) and
"unobservable"/internal (all other). If we make all assignments
observable, then what latitude is left for optimizers? If we make some
non-volatile assignments observable, but not others, where do we draw
the line? Obviously, the line has to be drawn very carefully, to leave
room for optimization on the one hand, and to make it easy enough (but
not too easy?) to write concurrent applications on the other hand. I
think this point needs very serious consideration.

Another question arises: do these new observable side effects share all
the characteristics of volatile? For example, must they all be strictly
ordered by sequence points? Or can they instead be ordered only by
synchronization points? Apparently, some people think the latter, which
would seem to require a brand-new category of side effect, to which I
won't even try to give a name on the fly. Of course there are also the
synchronization points themselves, which are probably yet another new
kind of side effect.

-- 
Clark Nelson		Vice chair, J16 (ANSI C++ standard committee)
Intel Corporation
clark.nelson at intel.com




More information about the cpp-threads mailing list