[linux-audio-dev] userspace atomic primitives for multithread and SMP applications?

Jack O'Quin joq at io.com
Tue Sep 9 18:35:01 UTC 2003


Michael Ost <most at museresearch.com> writes:

> I found some definitions in boost/detail/atomic_count.hpp, with gcc,
> win32, etc. flavors. I still haven't figured out how they are used! But
> at least there is source to play with.

Excellent!

Most of this is C++ language bindings for the low-level primitives.
It looks well-thought-out and cleanly implemented.  The portability
looks good.  I'm not a big fan of C++, but it is rather nice for stuff
like this.  It supports atomic operator++ and operator-- using
pthreads (with spin locks), glibc++ library interfaces, win32 stuff
and even the Linux kernel <asm/atomic.h> primitives, which
appropriately warns...

//  This implementation uses <asm/atomic.h>. This is a kernel header;
//  using kernel headers in a user program may cause a number of problems,
//  and not all flavors of Linux provide the atomic instructions.

I'm not sure how (or whether) one uses the interfaces in C, but it's
still an excellent collection of useful information about handling a
wide range of platform dependencies.

At this point I'm somewhat inclined to proceed with building my own
low-level package of useful primitives.  This package and the glibc
primitives look like the best models to base it on.  I'm going to try
using the SourceForge compiler farm as a test lab.

Thanks again for the pointer.

Regards,
-- 
  Jack O'Quin
  Austin, Texas, USA




More information about the Linux-audio-dev mailing list