Questions tagged [mesi]

The MESI protocol (known also as Illinois protocol) is a cache coherence and memory coherence protocol.

The MESI protocol (known also as Illinois protocol) is a cache coherence and memory coherence protocol. It or an extension like MESIF or MOESI is used nearly universally in multi-core CPUs and SMP systems.

http://en.wikipedia.org/wiki/MESI_protocol

MESI requires a core to take exclusive ownership of a cache line before writing to it, preventing multiple cores from storing conflicting values, or even from reading stale values.

(Cache itself is not the source of memory reordering: that's usually store buffers within individual cores. And on weakly-ordered ISAs, out-of-order execution of loads. See Does a memory barrier ensure that the cache coherence has been completed? no, cache is always coherent. A memory barrier waits for the store buffer to drain. It's a common misconception that stores make cache non-coherent and then barriers flush it manually.)

Relevant Q&As:

  • Can num++ be atomic for 'int num'? explains how atomic RMW operations are typically implemented in modern x86, by holding a cache line in Modified state between the load and store, not responding to Invalidate or RFOs until after the atomic transaction.
61 questions
4
votes
1 answer

Where and how is the MESI cache coherence protocol implemented?

I know the MESI protocol is used to implement cache coherence in multiprocessor systems. But I don't know how its implemented. Any help on this is very much appreciated.
mousey
  • 11,601
  • 16
  • 52
  • 59
4
votes
1 answer

With the MESI protocol, a write hit also stalls the processor, right?

I'm doing a project that is to implement a dual-processor system with some kind of cache coherency (for which I chose MESI) in VHDL. I just want to confirm this one thing: a write-hit on a shared cache line should cause the cache controller to send…
Einheri
  • 957
  • 1
  • 9
  • 22
3
votes
2 answers

In MESI cache coherence protocol, when exactly does the state of a cache line change if the data needs to be fetched from memory?

In MESI protocol when a CPU: Performs a read operation Finds out the cache line is in Invalid state There is no other non-invalid copies in other caches It will need to fetch the data from the memory. This will take a certain number of cycles to…
3
votes
1 answer

If write operation happens during exclusive cache access why is there data race?

I was reading about MESI protocol and cannot understand why there is data race if we have exclusive access on every write operation which consequently invalidated cache lines in other cores' caches? in this example: CYCLE # CORE 1 …
3
votes
1 answer

Does store buffer send read invalidate message or invalidate req message?

I think, to make the CPU continue executing subsequent instructions,the store buffer must do part of the MESI processing to get cache consistency, because the latest value is stored in store buffer and not cache. So the store buffer sends read…
Los Geles
  • 31
  • 2
3
votes
2 answers

What is the point of MESI on Intel 64 and IA-32

The point of MESI is to retain a notion of a shared memory system. However, with store buffers, things are complicated: Memory is coherent downstream of once the data hits the MESI-implementing caches. However, upstream of that, each core may…
Kay
  • 745
  • 5
  • 15
3
votes
1 answer

MESI protocol. Write with cache miss. Why needs main memory value fetch?

I'm wondering about MESI protocol implementation of writing with the allocation on write miss policy. Let's say that we have write request and got cache miss with no other copies of cache line. This diagram says that the next step is to fetch value…
Alex
  • 43
  • 4
3
votes
1 answer

Which MESI protocol states are relevant if cache with write-through policy is used?

I came across following question, while reading the slides of a lecture about cache coherency protocols: Which MESI states are relevant, if cache with write-through policy is used? The answer was also given: I (Invalid) and S (Shared Unmodified). I…
mike
  • 4,929
  • 4
  • 40
  • 80
3
votes
1 answer

MESI protocol understanding state transitions

In the state transition diagram shown below for the Illinois MESI protocol, why is there a Flush' signal when transitioning from state S to state I and a Flush signal when going from state E to state I upon observing a BusRdX signal. Wouldn't the…
lbj-ub
  • 1,425
  • 2
  • 19
  • 34
2
votes
0 answers

Does Cache Coherence always prevent reading a stale value? Do invalidation queues allow it?

In MESI protocol you write to the cache line only when holding it in the Exclusive/Modified state. To acquire the Exclusive state, you send an Invalidate request to all the cores holding the same cache line. But is there an micro-architecture where…
TwITe
  • 400
  • 2
  • 14
2
votes
0 answers

Why does MESI algorithm writes back incorrect data to RAM?

My professor refuses to answer this question and I am beginning to doubt he doesn't know the answer. I was given the following Suppose we have two threads running on parallel CPU's (writing and reading from same data block in RAM) First cache is in…
Rab
  • 147
  • 4
2
votes
1 answer

How does cache coherence work in multi-core and multi-processor architecture?

Let me explain my understanding and ask you to either confirm its correctness or correct me: There's a MESI protocol which allows for efficient cache coherence (https://en.wikipedia.org/wiki/MESI_protocol). It's the state of the art mechanism. For…
Sergey
  • 1,168
  • 2
  • 13
  • 28
2
votes
0 answers

MESI cost of sharing data across multiple threads

I want to measure the cache coherency (MESI) cost of reading a variable which another thread is writing to. I came up with the following test, but it reports the read only takes 2 cycles on average: // NB I used Microsoft's compiler so you will need…
intrigued_66
  • 16,082
  • 51
  • 118
  • 189
2
votes
1 answer

MESI- what happens when reading data currently being modified?

If I have a cache line of data and the first byte is being atomically modified, can I still read different bytes of data from this cache line concurrently? Or will my attempt to read know about the atomic update taking place and wait for it? I am…
user997112
  • 29,025
  • 43
  • 182
  • 361
2
votes
2 answers

Performance cost of MESI protocol?

The MESI (Modified, Exclusive, Shared, Invalid) protocol is used for CPU caches to communicate and ensure they are all using the latest value for a cache line. When one CPU modifies a cache line value, all other CPUs subscribed to this cache line…
user997112
  • 29,025
  • 43
  • 182
  • 361