[Top][All Lists]

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

Re: What would it take....

From: Samuel Thibault
Subject: Re: What would it take....
Date: Wed, 23 Dec 2009 09:09:41 +0100
User-agent: Mutt/1.5.12-2006-07-14

Da Zheng, le Wed 23 Dec 2009 15:49:01 +0800, a écrit :
> One more thing: is it enough to only use something like spin_lock  to protect 
> a variable in shared memory between two processes?


> (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).

Anyway, just use the spinlocks that hurd's glibc provides in
mach/spin-lock.h, they should just work.


reply via email to

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