volatile shared memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If I am interacting with shared memory, gcc doesn't know if another
process changes values.  This creates issues for optimization.  I know
that "volatile" can help address this, but it winds up causing a giant
mess of other problems (like, for instance, I can't pass a volatile
into memcpy.. or pretty much anything else from the standard
libraries).

So for instance, if I do something stupidly simple like busy-wait on a
shm value to change:

while (shm->index == oldindex) ;

gcc will kill that loop.

For simple things like this, and much more complicated things beyond
it, is there a way to cast something to "volatile" for one particular
usage?


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux