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

Kjetil S. Matheussen k.s.matheussen at notam02.no
Fri Apr 4 07:57:01 UTC 2003

On Thu, 3 Apr 2003, Tim Hockin wrote:

> > > i remember i have read a statement about a lock free ringbuffer
> > > implemented in C somewhere.
> >
> > courtesy of paul davis:
> >
> >     you should use a lock free ringbuffer. we will be adding example code
> >     to the example-clients directory soon. existing code is in ardour's
> >     source base (for C++). the example code will be in
> >     example-clients/capture_client.c.
> >
> > where ardour is ardour.sf.net. (i doubt there is anything hugely non-C in
> > the ringbuffer code proper).
> maybe it's just me, but I can't find said file...?

A lock free ringbuffer is not a big magic thing that take hours to make.
Its only two processes/threads/tasks/whatever sharing a ringbuffer. One of
them writes to the  buffer and the other one reads. The one that reads,
stop to read if there isnt more data to read, and the writer stops to
write if the buffer is full. To make it lockfree the reader checks the
writers pointer (or some similar method) to find out wheter data is
available, and returns zeroes or false or something if data was not
available. Now go ahead and implement your own. :)


More information about the Linux-audio-dev mailing list