Your laptop almost certainly has four or more CPU cores. Each core has its own private cache — a tiny, blazing-fast memory that holds copies of recently used data. Without caches, cores would stall waiting for main memory hundreds of times per second, and the chip would be far slower.
But that speed comes with a hidden problem. If Core 0 reads a variable into its cache and Core 1 also reads into its own cache, both are holding a copy. Now Core 0 writes a new value to . Core 1 still sees the old value. The two caches disagree — and programs that depend on shared data will compute wrong answers.
This is the cache coherence problem: how do you keep every core's cached copy of shared memory consistent, without destroying the performance advantage caches provide in the first place?
The dominant answer, used in virtually every x86 and ARM chip shipped in the last four decades, is the MESI protocol — a state machine named after its four states: Modified, Exclusive, Shared, and Invalid.
Comments
Loading comments...