Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The two terms aren't clearly defined, and it's not a black/white thing.</p> <p>Memory models can be extremely weak, extremely strong, or anywhere in between.</p> <p>It basically refers to the guarantees offered about concurrent memory accesses.</p> <p>Naively, you would expect a write made on one thread, to be immediately visible to all other threads. And you would expect events to appear in the same order on all threads as well.</p> <p>But in a weaker memory model, neither of those may hold.</p> <p>Sequential consistency is the term for a memory model which guarantees that events are seen in the same order across <em>all</em> threads. So a memory model which ensures sequential consistency is pretty strong.</p> <p>A weaker guarantee is causal consistency: the guarantee that events are observed after the events they depend on.</p> <p>In other words, if you first write a value <code>x</code> to some address <code>A</code>, and then write a second value <code>y</code> to the same address, then no thread will <em>ever</em> read the value <code>y</code> after reading the <code>x</code> value. Because the two writes are to the same address, it would violate causal consistency if not all threads observed the same order. But this says nothing about what should happen to <em>unrelated</em> events. The result of writing a third value to a different memory address could be observed at absolutely <em>any</em> time by other threads (so different threads may observe events in a different order, unlike under sequential consistency)</p> <p>There are plenty other such levels of "consistency", some stronger, some weaker, and offering all sorts of subtle guarantees about what you can rely on.</p> <p>Fundamentally, a stronger memory model is going to offer more guarantees about the order in which events are observed, and will normally guarantee behavior closer to what you'd intuitively expect.</p> <p>But a weaker model allows more room for optimization, and especially, it scales better with more cores (because less synchronization is required)</p> <p>Sequential consistency is basically free on a single-core CPU, is doable on a quad-core, but would be prohibitively expensive on a 32-core system, or a system with 4 physical CPUs. Or a shared-memory system between multiple physical machines. </p> <p>The more cores you have, and the further apart they are, the harder it is to ensure that they all observe events in the same order. So compromises are made, and you settle for a weaker memory model which makes looser guarantees.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload