[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: volatile or not volatile
On Tue, Mar 04, 2003 at 07:17:49PM +0100, Frank A. Uepping wrote:
> Do these mechanisms (spinlocks, semaphores, atomic_t) make sure
> that they always operate on the most actual versions of the shared data?
> Have I to do some *special action* to ensure this, like qualifying the shared
> data volatile?
> What mechanism exists to enforce *memory sync* anyway?
Combinbing semaphores or spinlocks with memory barriers will enforce
this. See mb(), wmb() (write memory barrier), and rmb() (read memory
barrier).
Of course, using volatile on primitive types should do the job too.
--
"I'm not sure which upsets me more: that people are so unwilling
to accept responsibility for their own actions, or that they are
so eager to regulate everyone else's." -- Kee Hinckley
PGP signature