Hacker News new | ask | show | jobs
by amelius 1544 days ago
relatively simple until you get into cache coherence (not an issue if you mark the memory as volatile)
2 comments

The volatile keyword in C has nothing to do with cache coherence and does not prevent cache coherence issues.

It just forces the compiler to generate all memory accesses on this variable. And if this variable is in a cached memory region, then it opens the door to very usual cache coherency problems

Memory mapped IO is never cached as far as I know, so at least that's not a concern.
You'd still have to tell the compiler it's volatile if you were writing into the DMA buffer directly for some reason. GP just used the wrong words to say what they meant.