[linux-audio-dev] Lock Free Ringbuffer in C ?
David Olofson
david at olofson.net
Sat Apr 5 13:55:00 UTC 2003
On Friday 04 April 2003 17.15, torbenh at gmx.de wrote:
[...]
> res = sfifo_write(sf, &buf, j);
> if(res != j)
> {
DOH! Sorry, I'm in a hurry and misread your code.
Well, we're talking about a basic lock free FIFO here, based on atomic
reads and writes of two indices. Proper blocking read() and write()
would require talking to the OS scheduler one way or another (block +
wake up functionality), and that's not even possible on some of the
platforms this code is used on.
That said, I do have a version with busy-waiting versions, meant for
use with IRQs in environments without threads. I wouldn't recommend
using this on any multitasking OS, though, except possibly for IPC
across CPUs in SMP systems in some special cases.
//David Olofson - Programmer, Composer, Open Source Advocate
.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -'
--- http://olofson.net --- http://www.reologica.se ---
More information about the Linux-audio-dev
mailing list