"Bart Van Assche" <[EMAIL PROTECTED]> writes: > * As known the compiler may reorder function calls and assignments > to non-volatile variables if the compiler can prove that the called > function won't modify that variable. This becomes problematic if the > variable is modified by more than one thread and the called function > is a synchronization function, e.g. pthread_mutex_lock(). This kind of > reordering is highly undesirable. This is why any variable that is > shared over threads has to be declared volatile, even when using > explicit locking calls.
What happens in practice is that pthread_mutex_lock and friends are magic functions. In gcc, this magic implemented using inline assembler constructs. Ian