« Return to Thread: Some threading bits

Re: Some threading bits

by Chris Robinson-5 :: Rate this Message:

Reply to Author | View in Thread

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.
_______________________________________________
Openal-devel mailing list
Openal-devel@...
http://opensource.creative.com/mailman/listinfo/openal-devel

 « Return to Thread: Some threading bits

LightInTheBox - Buy quality products at wholesale price!