volatile

eles eles at eles.com
Mon Sep 9 09:00:46 PDT 2013


Among the intended uses of volatile is to "allow access to memory 
mapped devices" (quoting wikipedia).

This play an immense role in the embedded, signaling to the 
compiler that the content of that variable/address could change 
without notice.

It is not because other thread would change it. It is because it 
is a hardware device that is mapped at that address and its 
behavior is commanded/interrogated by R/W operations.

As such, R/W operations of such variables should never be cached 
or optimized away, but always performed.

AFAIK, the volatile keyword went away and I am not sure it was 
intended for this.

Does D peek() and poke() functions (or similar) that guarantee 
R/W operations at a memory address?

Thanks.


More information about the Digitalmars-d-learn mailing list