[cpp-threads] modes, interlude

Peter Dimov pdimov at mmltd.net
Mon May 9 23:50:53 BST 2005


Boehm, Hans wrote:

> 2) I do like the idea of providing the ordering constraint as a
> template or function argument.  It makes it much easier for the user
> to implement the "atomically multiply by 17 and add 1" function
> in terms of CAS, without redoing it for every possible ordering
> constraint.  And that reinforces point (1).  Do we all agree?

Providing a complete "constraint algebra" with acq == hlb | hsb, rel == slb 
| ssb, none | x == x, full == acq | rel, x | full == full, x & full == x, x 
& none == none also allows, for example:

void atomic_decrement( m1, m2, addr ); // has msync m1 on nonzero and m2 on 
zero

to be implemented in terms of fetch_and_add with msync m1 | m2. And probably 
various other nice things that I haven't considered.

It also simplifies implementations (of course the simplification is offset 
by the 16 modes and may require template wizardry, but still...) by allowing 
easy fallback from m1 to m2 when m1 & m2 == m1.

I may submit a prototype of the above for consideration if there is interest 
in pursuing this approach.

The important open question for me is: how do we specify these things? They 
are completely outside the memory model. 





More information about the cpp-threads mailing list