[fpc-devel] volatile variables
Michael Schnell
mschnell at lumino.de
Wed Jun 29 15:34:51 CEST 2011
On 06/28/2011 07:05 PM, Vinzent Höfler wrote:
> On Tue, 28 Jun 2011 15:54:35 +0200, Michael Schnell
> <mschnell at lumino.de> wrote:
>
> No, it can't. "volatile" just ensures that accessing the variable
> results in
> actual memory accesses. That does not mean cache-coherence, so another
> core
> may still see other (as in "older") values.
This is done by the hardware (but not aggressive enough to ensure atomic
instructions to work without additional bus-locking)
> It should not.
Right you are. We found that a compiler needs to consider any function
call as a "volatile barrier" and is not allowed to cache any
memory-value in a register as the called function might somehow know the
address and access that variable (even in a single threaded application).
As a CS "Enter" and "Leave" is done as a function call this aspect of my
original question is solved.
Thanks,
-Michael
More information about the fpc-devel
mailing list