阅读:1245回复:4
xchg 或者 and 指令会不会产生数据位丢失??
例如 外设可能不定期 dma write 32位变量 var1
而在程序里 xor eax, eax xchg eax, var1 必须这样获取和更新 var1, 而总线上,内存只有读写2种命令 所以我担心在执行 xchg半中央时 dma write产生了,这就会 造成var1的某些位丢失. 请问这里的大老们,CPU会不会保证 xchg指令执行期间 内存总线 一直被cpu 占着,而不会被抢走? 谢谢!! [编辑 - 8/7/04 by yebear] |
|
沙发#
发布于:2004-08-11 18:03
你的担心是多余的
IA-32 processors provide a LOCK# signal that is asserted automatically during certain critical memory operations to lock the system bus. While this output signal is asserted, requests from other processors or bus agents for control of the bus are blocked. Software can specify other occasions when the LOCK semantics are to be followed by prepending the LOCK prefix to an instruction. |
|
板凳#
发布于:2004-08-10 23:41
再请问前面的几位大老:
LOCK#信号是锁定总线的吗?我看Intel一个文档好像说这个信号是用在多CPU之间互拆的,跟锁定内存总线没什么关系啊。 |
|
地板#
发布于:2004-08-09 13:21
The LOCK prefix can be prepended only to the following instructions and only to those forms
of the instructions where the destination operand is a memory operand: ADD, ADC, AND, BTC, BTR, BTS, CMPXCHG, CMPXCH8B, DEC, INC, NEG, NOT, OR, SBB, SUB, XOR, XADD, and XCHG. If the LOCK prefix is used with one of these instructions and the source operand is a memory operand, an undefined opcode exception (#UD) may be generated. An undefined opcode exception will also be generated if the LOCK prefix is used with any instruction not in the above list. (IMPORTANT:) The XCHG instruction always asserts the LOCK# signal regardless of the presence or absence of the LOCK prefix. [编辑 - 8/9/04 by boly81] |
|
地下室#
发布于:2004-08-09 09:03
用CMPXCHG,或CMPXCHG8B。。。。。
或者在指令前用LOCK锁定总线。。。。 |
|
|