Hi,

Samuel Thibault wrote:
>> (or volatile variable + memory barrier)
> 
> You do not need both. If you use a memory barrier, you don't need to
> tell the compiler "volatile", since the memory barrier already tells it
> that things may have changed. If you use volatile, the compiler won't
> optimise instructions so it would "work" too ; note however that it's
> not SMP safe (it may even not be premption-safe, depending on which
> instruction the compiler eventually uses).
We don't need both? If there is only volatile, instructions might be executed 
out of order and compilers might also reorder instructions.
As far as I see, spin_lock always uses "volatile" keyword to define spin_lock 
variables and there is "memory" in the list of clobbered registers of the 
inline assembly code. Doesn't "memory" mean memory barrier?
> 
> Anyway, just use the spinlocks that hurd's glibc provides in
> mach/spin-lock.h, they should just work.
> 
Zheng Da


Reply via email to