Re: [linux-audio-dev] lock-free ring buffer code

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] lock-free ring buffer code
From: Steve Harris (S.W.Harris_AT_ecs.soton.ac.uk)
Date: Fri Apr 04 2003 - 16:20:18 EEST


On Fri, Apr 04, 2003 at 07:48:20 -0500, Paul Davis wrote:
> there is one aspect of the LFRB that bothers me. as has been explained
> many times, the monotonic motion of the read/write pointers is
> key. but when one the reader/writer moves the pointer to the end of
> the buffer and wraps it around, that operation does not cause
> monotonic motion (its semantically monotonic, but in fact the pointer
> value goes from high to low). i've never quite satisfied myself that
> this is threadsafe.

I think its fine because the addressing technique of the ringbuffer is that
the address is evaluated by masking the pointer offset number, and this is
true for every access (tecnically speaking, obviously you dont always have
to perform the mask).

The behaviour is also correct if you address backwards (as in a FIR
filters ringbuffer, ie. back in time).

Of course this is only true if the buffer is power-of-two sized.

- Steve


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Fri Apr 04 2003 - 16:28:11 EEST