如何高速缓存一致性协议执行原子? [英] How does the cache coherency protocol enforce atomicity?

查看:271
本文介绍了如何高速缓存一致性协议执行原子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解原子可以操作来保证像 XSUB(),不使用锁定 preFIX ,所依托的高速缓存一致性协议(MESI / MESIF)。

I understand atomicity can be guaranteed on operations like xsub(), without using the LOCK prefix, by relying on the cache coherency protocol (MESI/MESIF).

1)如何缓存一致性协议做到这一点?

1) How can the cache coherency protocol do this???

它让我怀疑缓存一致性协议可以强制执行的原子性,我们为什么需要特殊的原子类型/指令等?

Its making me wonder if the cache coherency protocol can enforce atomicity, why do we need special atomic types/instructions etc?

2)如果MOSI实现跨多核心系统的原子操作又是什么锁定的目的是什么?遗产?

2) If MOSI implements atomic instructions across multi-core systems then what is the purpose of LOCK? Legacy?

3)如果MOSI实现原子操作和MOSI用于所有指示中那么为什么原子操作花费这么多?当然,性能应该是一样的正常的指令。

3) If MOSI implements atomic instructions and MOSI is used for all instructions- then why do atomic instructions cost so much? Surely the performance should be same as normal instructions.

推荐答案

有在86没有 XSUB 指令,但有一个 XADD ;)

There is no xsub instruction in x86, but there is an xadd ;)

您应该阅读有关部分的锁定 preFIX在指令集的,而部分的 8.1锁定ATOMIC营运的的的软件开发人员手册卷3A中:系统编程指南,第1部分

You should read the section about the LOCK prefix in the Instruction Set Reference, and the section 8.1 LOCKED ATOMIC OPERATIONS in the Software Developer's Manual Volume 3A: System Programming Guide, Part 1.

单CPU 的指的单核的时下,有自己的缓存。当有多个内核的多个缓存(物理上在相同或单独的CPU芯片),他们使用的一些高速缓存相关性协议。在梅西奇的情况下,执行原子指令的核心将首先保证它有一个包含操作数的高速缓存行的所有权,并将其标记修改,另外锁定它。如果另一核心需求的高速缓存行,它会做一个读操作,它的主人内核将窥探和直至原子操作完成延迟回答。

The single CPU refers to a single core nowadays, with its own cache. When you have multiple caches for multiple cores (physically in the same or separate cpu chips) they use some cache coherency protocol. In case of MESI, the core executing the atomic instruction will first ensure it has ownership of the cache line containing the operand and marks it modified, additionally locking it. If another core needs the cache line, it will do a read operation which the owner core will snoop and delay the answer until the atomic operation completes.

在单CPU的单核系统,大部分的操作都是原子相对于除了使用字符串指令穿线 REP preFIX因为档期的中断,因此背景交换机只发生在指令边界。然而,硬件设备可以观察到非原子行为。

On single-cpu single-core systems, most instructions are atomic with respect to threading except for string instructions using a REP prefix because scheduling interrupts and thus context switches only happen on instruction boundaries. A hardware device could however observe non-atomic behaviour.

这篇关于如何高速缓存一致性协议执行原子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆