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?
Yes. > (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. Samuel