Re: [linux-audio-dev] lock-free fifos

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

Subject: Re: [linux-audio-dev] lock-free fifos
From: Ingo Oeser (ingo.oeser_AT_informatik.tu-chemnitz.de)
Date: Sat May 11 2002 - 21:20:10 EEST


Hi Tim,

On Sat, May 11, 2002 at 03:51:09PM +0200, Tim Goetze wrote:
> i'm evaluating the following construct to implement a lock-free fifo
> that allows more than one thread on the writer side:
>
> here, the i386 'xadd' instruction atomically adds 'i' to the counter
> variable and returns the counter value before the add (obviously this
> restricts the fifo size to powers of two so counter overflow can
> safely be ignored).
>
> do you happen to know about the availability of an analogon to this
> code on other processors than i386?
 

Look into the implementation of atomic_add() of your favorite
arch, because you just re-invented it badly ;-)

The problem is, that on some archs atomic operations are
implemented using privileged instructions, so they cannot be used
in user space. But Linux 2.5 will have fast user space mutexes
(the implementor calls these "futexes"), so you are basically
wasting your time here ;-)

Regards

Ingo Oeser

-- 
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth


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

This archive was generated by hypermail 2b28 : Sun May 12 2002 - 08:43:20 EEST