[cpp-threads] Brief example ITANIUM Implementation for C/C++MemoryModel

Alexander Terekhov alexander.terekhov at gmail.com
Fri Jan 2 22:36:58 GMT 2009


On Fri, Jan 2, 2009 at 9:11 PM, Paul E. McKenney
<paulmck at linux.vnet.ibm.com> wrote:
[...]
>> Now, what is your reasoning regarding
>>
>> P1: Y.store(1, relaxed);
>> P2: Z.store(1, relaxed); fence(seq_cst); a = Y.load(relaxed);
>> P3: b = Y.load(relaxed); fence(seq_cst); c = Z.load(relaxed);
>>
>> and a=0, b=1, c=0 outcome?
>
> P1's and P2's stores are relaxed, and therefore are not guaranteed to be
> seen in the same order by all threads.  So it is perfectly legal for P2
> to think that Z.store() happened first and for P3 to think that Y.store()
> happened first.

Arguendo, okay.

Well, but recall that your own recipe is to "put an
atomic_thread_fence(seq_cst) to segregate the operations."

So where do you put an additional fence(seq_cst) in

P1: Y.store(1, relaxed);
P2: Z.store(1, relaxed); fence(seq_cst); a = Y.load(relaxed);
P3: b = Y.load(relaxed); fence(seq_cst); c = Z.load(relaxed);

to preclude non-sequentially consistent  a=0, b=1, c=0 outcome?

What is your reasoning?

TIA.

regards,
alexander.



More information about the cpp-threads mailing list