</>EmbeddedInterview

What is cache coherency in a multicore ARM system?

MediumMicrocontrollers & ARM Cortex-M

Cache coherency ensures that participating CPU cores observe consistent values for a shared memory location according to the hardware coherency protocol.

1. Example

Two cores initially cache the same line containing x = 10. Core 0 obtains permission to write and changes x to 20. The protocol may invalidate Core 1's stale copy. After the required software synchronization, Core 1's next read obtains the updated value from the appropriate cache or memory.

Core 0Cache line: x = 20Core 1Old x = 10 invalidatedCoherent interconnect / cache hierarchyDRAM / memory

A modified cache line need not have reached DRAM for another coherent core to obtain its current value.

2. Coherency vs consistency

Coherency concerns the ordering and visibility of accesses to the same memory location. The memory consistency model governs allowed ordering relationships across locations. A flag/data publication pattern still requires appropriate acquire/release or other synchronization.

3. False sharing

Different variables in the same cache line can cause unnecessary invalidations when different cores modify them. Data layout and per-core storage can reduce this contention.

Interview takeaway: Cache coherency does not make count++ atomic, replace memory barriers, or guarantee that every DMA device participates in the same coherence domain.