How the system ensures consistency between memory and cache

For example, if I write to a specific memory location (for example: DMA transfer), how will it be affected in my cache?

+4
source share
2 answers

Cache is a CPU function; if you write to memory via the CPU, the cache will be updated and will remain unchanged.

If you write to the memory in some other way (for example, DMA transfer, as you think), you need to (possibly) first clear the cache, and then tell the CPU that the cache is invalid. How you do this depends on your system - for example, INVD and WBINVD for x86.

Two good reading articles on cache coherence and DMA Understanding Caching and Using DMA (both by James Bottomley, published in Linux Magazine, "Caching" in issue 117, January 2004 and "DMA" in release 121, May 2004).

+1
source

Note: INVBD and WBVD instructions are private instructions, so you cannot run them directly from user space.

0
source

All Articles