[cpp-threads] High-level vs. low-level

Boehm, Hans hans.boehm at hp.com
Thu Jul 13 23:13:20 BST 2006


> -----Original Message-----
> From: Alexander Terekhov
> > [Peter:]
> > This is a very good question. I'm still undecided on whether:
> >
> >     atomic_load_acq( &x );
> >
> > should work on x being a plain int.
> 
> Should not.
> 
I think there is a strong argument to the contrary: Existing practice.
That's why the current proposal takes the opposite route, in spite of
the fact that Lawrence once convinced me of Alexander's opinion.

I think nearly every compiler currently provides intrinsics that perform
atomic read-modify-write operations on ordinary integers.  I have yet to
find one that provides a corresponding atomic read (or simple store)
operation, so I think these are all somewhat broken.  (And you can't
reasonably provide those operations without seriously addressing
ordering issues, which they generally don't.)  But certainly by 2009
there will be a fair amount of code that uses them, and we want this
code to be converted.  I think it might be very hard to do the
conversion if you require atomic<T> (or some C equivalent) declarations,
since some of the changes might then touch interfaces creating binary
compatibility issues.  If sizeof(atomic<T>) != sizeof(T) that probably
becomes worse.

There is/was a parallel discussion on the gcc-patches at gcc.gnu.org list
that also touched on these issues.  (See
http://gcc.gnu.org/ml/gcc-patches/2006-07/msg00588.html and prior
messages.)

Hans



More information about the cpp-threads mailing list