2 ms·
> Surely living a mutex requires synchronising across the cores of a CPU Right it's done over cache coherence, which doesn't need to reach all the way out to m
by chrisseaton 6y ago
> Surely living a mutex requires synchronising across the cores of a CPU
Right it's done over cache coherence, which doesn't need to reach all the way out to main memory. And that's only if it's contested.
- dragontamer 6y agoA contested mutex lock / unlock is over L3 cache. Uncontested mutex lock/unlock is just a swap instruction followed (or in "unlock": preceded) by a memory barrier. The flush pushes data to L3 cache, where it can be shared between multiple cores. (L1 and L2 cache is local to a core). L3 cache is far closer than main-memory, and roughly 20ns these days. ------- In "actuality", its more of a MESI message, but in the abstract its your L3 caches communicating with each other and synchronizing.
- chrisseaton 6y agoNot sure if you're agreeing with me or contradicting me? Isn't that what I said?