[cpp-threads] memory model

Peter Dimov pdimov at mmltd.net
Fri May 6 11:23:21 BST 2005


Boehm, Hans wrote:
>> (a, b) + (c, d) is another example.
>
> My problem with all of this is that the standard only talks about the
> position of the sequence points in an execution.  Thus if I
> have f((a,b), (c,d)) with an execution of, for example:
>
> 1: <evaluate a>
> 2: <evaluate b>
> 3: <evaluate c>
> 4: <evaluate d>
> 5: <call f>
>
> then the standard tells me there are sequence points between 1 and 2
> and 3 and 4.  I know that a and d can be executed in any order, and
> I'm positive the committee agrees, but I don't see how sequence points
> say that.

Once you choose an execution, the order is fixed, and the concept of 
sequence points is no longer relevant. But the above is not the only 
possible execution.

1: <evaluate c>
2: <evaluate a>
3: <evaluate b>
4: <evaluate d>
5: <call f>

If a and c are complex expressions, 1 and 2 can also be interleaved.

The sequence points impose constraints on the set of possible executions. 
They aren't applied to the execution itself. At least this is my 
understanding of the concept. In fact there is no standard requirement for a 
and c to even be evaluated sequentially; they can be evaluated in parallel. 
There is a requirement that writes to the same object must be separated by a 
sequence point (else the behavior is undefined), so this parallel execution 
is guaranteed not to have races. 





More information about the cpp-threads mailing list