Does a memory barrier ensure that the cache coherence has been completed?

后端 未结 4 2069
眼角桃花
眼角桃花 2020-11-28 04:01

Say I have two threads that manipulate the global variable x. Each thread (or each core I suppose) will have a cached copy of x.

Now say th

4条回答
  •  广开言路
    2020-11-28 04:56

    If no other processor has X in its cache, doing x=5 on processor A will not update the caches in any other processor. If processor B reads variable X, processor A will detect the read (this is called snooping) and will provide the data, 5, on the bus for processor B. Now processor B will have the value 5 in its cache. If no other processor reads variable X then their caches will never be updated with the new value 5.

提交回复
热议问题