[Openal-devel] Some threading bits
Chris Robinson
chris.kcat at gmail.com
Thu Jul 10 23:56:58 PDT 2008
On Thursday 10 July 2008 11:33:50 pm Killian De Volder wrote:
> Why does this happen even if it's volatile ?
> Volatile only guarantees the int will be written to memory straight away
> / without any optmalizations.
> However, if 2 threads load the memory manipulate and safe it, there is
> no guarantee that the register will be in sync.
That's likely true. In this case, though, all that happens is one thread
continually reads it, waiting for another to write/change it once. The
volatile is needed here to prevent GCC from assuming the variable never
changes since the thread reading it doesn't write to it.
> > Anyway, a mutex should be used there if it's really important (can it
> > segfault? Or just causes noise?).
If a thread segfaults, it should take the whole process with it. The worst
that could happen is that it locks up/enters an infinite loop, in which case
a mutex won't do anything better.
More information about the Openal-devel
mailing list