When can the CPU ignore the LOCK prefix and use cache coherency?

后端 未结 2 1339
说谎
说谎 2021-02-04 19:04

I originally thought cache coherency protocols such as MESI can provide pseudo-atomicity but only across individual memory-load/store instructi

2条回答
  •  执笔经年
    2021-02-04 19:36

    Reading the excerpt you give, I don't find it contradictory to using of LOCK-ed instruction. For example, consider INC instruction. Without the LOCK, it can read the original value having its cache line in SHARED state which does not prevent other cores on the same cache from concurrent reading of the same value before storing the same incremented result = data race.

    I interpret the quote as the data integrity is guaranteed per cache line granularity, the additional care may not be necessary when the data fits one cache line. But if the the data crosses the boundary of two cache lines, it is necessary to assert that modifications for both of them will be treated atomically.

提交回复
热议问题