Many modern computer systems and most multicore chips (chip multiprocessors) support shared memory in hardware. In a shared memory system, each of the processor cores may read and write to a single shared address space. For a shared memory machine, the memory consistency model defines the architecturally visible behavior of its memory system. Consistency definitions provide rules about loads and stores (or memory reads and writes) and how they act upon memory. As part of supporting a memory consistency model, many machines also provide cache coherence protocols that ensure that multiple cached copies of data are kept up-to-date. The goal of this primer is to provide readers with a basic understanding of consistency and coherence. This understanding includes both the issues that must be solved as well as a variety of solutions. We present both highlevel concepts as well as specific, concrete examples from real-world systems.
If you want to learn about memory models, how modern CPUs work and why they work this way this is the book. Don't start with descriptions of volatile in C++ or any language but start with this book. It's written by academics so it's dense and it provides a steep learning curve. And it's good that it does it this way, because you will learn a lot in a short period of time.
I love the approach authors took to first separate the consistency from the coherence, and then build on top of it. I love the samples provides when discussing the ideas provides in a chapter. I love that sometimes, you're given a choice to jump over some sections if you don't want to dive that deep.
If you're looking for a book on memory consistency and cache coherence, this is it.
This book is rad! But requires a bit of a galaxy brain. The good parts: - this is the fundamental level explanation why concurrency is hard. all those "re-orderings", "data races", "consistency", "total store orderings" are explained at a hardware level and from an algorithmic perspective. - the book does an excellent job at building intuition with simplified solutions at start and then gradually adding optimizations to get to the "real deal" - most of the topics are covered from multiple perspective: algorithmic, hardware, formalism. - despite academic tone, it tries to be reader friendly: hard topics are explained multiple times using different illustrations, formalisms are walked through using step-by-step execution, etc. - tons of links if you need to go deeper
The bad parts: - it's not a casual read and requires galaxy brain mode to get to the end. while some chapters are prefaced with "you can skip it, if don't need these details", jumping in the middle of the book is most likely a bad idea.