Re: [LAU] Simple, easy multithreaded circular buffer library for Linux?

From: Fons Adriaensen <fons@email-addr-hidden>
Date: Fri Oct 17 2008 - 23:09:24 EEST

On Fri, Oct 17, 2008 at 02:33:00PM -0400, Paul Coccoli wrote:

> There's no chance that a compiler optimization is hiding the bug,
> because we haven't turned on optimization.

But there is nothing that stops the compiler from writing
read_ptr any number of times it wants unless you make that
variable volatile.

> HOWEVER, if you go back
> to the original version and REMOVE the volatile qualifiers, then
> re-compile with -O2, NOW a compiler optimization is hiding the bug
> (and the test passes)! The rb->read_ptr is presumably cached in a
> register and hence only modified once (giving the same affect as the
> patch).

Indeed. The original version really invited the problem,
by *forcing* the compiler to write read_ptr twice.

Ciao,

-- 
FA
Laboratorio di Acustica ed Elettroacustica
Parma, Italia
Lascia la spina, cogli la rosa.
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
Received on Sat Oct 18 00:15:06 2008

This archive was generated by hypermail 2.1.8 : Sat Oct 18 2008 - 00:15:06 EEST