Jaroslav Kysela wrote:
> 
> On Mon, 17 Feb 2003, Abramo Bagnara wrote:
> 
> > You're wrong: xadd is atomic but xadd/read/saturation/write is not.
> >
> > Without the loop I've added you risk to write on hw_ring_buffer an *old*
> > value:
> >
> > A:            B:
> > xadd
> > read
> >               xadd
> >               read
> >               saturate
> >               write
> > saturate
> > write
> 
> I see, the read/saturate/write must be atomic, too. In this case, it would
> be better to use a global (or a set of) mutex(es) to lock the hardware
> ring buffer. The futexes are nice.

They are nice indeed, but definitely not the right solution here.

Although I don't know if it's the absolute best solution, the 'retry'
approach I've proposed is far better and much more efficient.

-- 
Abramo Bagnara                       mailto:[EMAIL PROTECTED]

Opera Unica                          Phone: +39.546.656023
Via Emilia Interna, 140
48014 Castel Bolognese (RA) - Italy


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to