[LAD] a *simple* ring buffer, comments pls?

Dan Muresan danmbox at gmail.com
Tue Jul 12 12:44:23 UTC 2011


> updating the read index, yes?  how is that expressed as portably as
> possible?  Does __sync_synchronized reliably do that?  (The
> documentation is surprisingly short...)

I wonder if

{
pthread_mutex_t dummy = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&dummy);
pthread_mutex_unlock(&dummy);
}

doesn't provide a portable full memory barrier. The dummy is different
each time, so no contention -- but still inefficient since  this would
be a 2-step full barrier. Nevertheless, it could be a portable
fallback.

Oh, and you probably need a barrier in the consummer too, just
reasoning from symmetry.

-- Dan



More information about the Linux-audio-dev mailing list