digitalmars.D.learn - volatile
- eles (15/15) Sep 09 2013 Among the intended uses of volatile is to "allow access to memory
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.
Sep 09 2013