Re: [LAD] Atomic Operations

From: Arnold Krille <arnold@email-addr-hidden>
Date: Tue Dec 15 2009 - 22:05:44 EET

Hi,

On Tuesday 15 December 2009 19:33:18 Gabriel M. Beddingfield wrote:
> On Tue, 15 Dec 2009, Tim Blechmann wrote:
> >> http://github.com/radarsat1/dimple/blob/master/src/CircBuffer.h
> > you should add memory barriers, when reading or writing to the reader or
> Actually, his implementation is similar to ringbuffer.c in
> libjack... and assumes that reading and writing can happen
> atomically (as was pointed out by someone else) -- which can
> be managed with single reader / single writer
> requirement.[a]
> Unless I've misunderstood the code, ringbuffer.c is /not/
> using special atomic operations.

Why should a single-reader-single-writer ring-buffer need atomic operations?

The reader increments the read-pointer (which doesn't have to be a pointer)
last when its finished, the writer increments the write-pointer last when it
has written. All other access is read-only. No problems. (At least in my app.)

increment = read the old value, add one, modulo (or bit-mask) the size, write
the new value

Arnold

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev

Received on Wed Dec 16 00:15:03 2009

This archive was generated by hypermail 2.1.8 : Wed Dec 16 2009 - 00:15:03 EET