[cpp-threads] Draft Plan for Threads in C++

Ben Hutchings ben at decadentplace.org.uk
Thu Apr 28 12:35:38 BST 2005


Lawrence.Crowl at Sun.com wrote:
> "Boehm, Hans" <hans.boehm at hp.com> writes:
<snip>
>  >Should it provide specific "atomic" classes like the Java one?
>  >Should it be a template on arbitrary types, which can just say "not
>  >implemented" if you ask for atomic 276 byte structs with overloaded
>  >assignment?  Do we agree that the operations should be (op,
>  >ordering_constraint) pairs?  Is the ordering_constraint a template
>  >parameter?  What about optional hardware-dependent functionality?
> 
> All good questions.  My current thinking is to keep it simple, e.g. a
> few lock objects, an atomic integer with atomic += operations, a
> compare-and-swap operation.
<snip>

With respect, I think this is naive.  Where available, atomic += may be
highly constrained; for example on IA64 it can add or subtract 1, 4, 8
or 16.  CAS isn't universally available and on the ARM architecture it
probably still won't be commonly available in 2009 without OS support.
If I'm not mistaken, most lockless algorithms require ordering
constraints.

Ben.

-- 
Ben Hutchings
Horngren's Observation:
                   Among economists, the real world is often a special case.




More information about the cpp-threads mailing list