[cpp-threads] Causality on more than two processors, write atomicity

Herb Sutter hsutter at microsoft.com
Mon Sep 5 21:42:39 BST 2005


The example was:
> >>P1: Y = 1; Y = 2;
> >>P2: if( Y == 2 ) { Z = 1; }
> >>P3: if( Z == 1 ) { assert( Y >= 1 ); }

Doug wrote:
> The JMM doesn't promise this. Somewhere in the JMM archives is a
> discussion about this kind of lack of transitivity. It is one
> ot the reasons that the formal models are more complicated than
> you'd wish.

Does that mean I can't always reliably maintain invariants, if I'm using
unsynchronized updates (no locks) and the variables involved in the
invariant can be updated by more than one thread over the life of the
program?

Can you summarize the issues in that thread, or point to an existing
summary? I imagine one issue is the cost doing more than pairwise
(possibly stop-the-system) cache synchronization?

Herb





More information about the cpp-threads mailing list