[linux-audio-dev] Re: Shared memory

Ingo Oeser ingo.oeser at informatik.tu-chemnitz.de
Fri Jul 25 23:15:01 UTC 2003


On Fri, Jul 25, 2003 at 04:58:35PM +0300, Juhana Sadeharju wrote:
> So, there is no "do not optimize away apperent volatile variables"?

Please define "apperent volatile". For the shmat() path you _may_
find out, that a variable coming from that space will be
volatile. But do some casts and some pointer math, pass it to an
external function sometimes and this information is completely lost.

> Volatile variables in shmclient are easily recognized -- at least
> I recognized them.

Because you wrote the code. The compiler is just trying to
understand, what you want and tries to find an equivivalent
match, that performs better. It's always the same with language.
There is no "guess what I think", there is communication. The
rules are simple, because the computer is stupid (but damn fast!).

So what Paul says is the way to communicate.

> It is the array variable which content is only
> read but never written.

So the read was optimized away correctly ;-)

> No such optimization flag? Can't believe that compilers are that dump.

What you want is -fvolatile or declare the content of the array
volatile. There is no way around that. And that's just the x86.
On other machines, you should even use memory barriers.


Regards

Ingo Oeser



More information about the Linux-audio-dev mailing list