[Top][All Lists]

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

Re: What would it take....

From: Da Zheng
Subject: Re: What would it take....
Date: Wed, 23 Dec 2009 16:46:34 +0800
User-agent: Thunderbird (Macintosh/20090812)


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

[Prev in Thread] Current Thread [Next in Thread]