4 ms·
What is a memory model?
by da39a3ee 5y ago
What is a memory model?
- tialaramex 5y agoIn this context the Memory Model tells us about how memory seems to work in our concurrent program. It only matters if your program has concurrency (more than one apparently simultaneous execution context, today often because there is physically more than one CPU core) and the concurrent elements of the program are able to read or write the same memory. Notice that at the speeds CPUs run, the actual main "memory" of the computer may take a relatively long time to read from or write to and so we use multiple layers of caches further complicating the problem. We want: A model that's fast yet also a model that's understandable for merely human programmers. This turns out to be a difficult problem.
- pornel 5y agoA definition of what exactly happens when you write to RAM. It turns out to be much more complicated than "the data is just written", because there are other threads that could be reading and writing at the same time, multiple layers of inconsistent caches, and clever compiler optimizations or hardware that can change execution order of the code.