yebear
驱动牛犊
驱动牛犊
  • 注册日期2001-05-18
  • 最后登录2013-04-05
  • 粉丝0
  • 关注0
  • 积分9分
  • 威望51点
  • 贡献值0点
  • 好评度18点
  • 原创分0分
  • 专家分0分
阅读:1245回复:4

xchg 或者 and 指令会不会产生数据位丢失??

楼主#
更多 发布于:2004-08-07 14:58
例如 外设可能不定期 dma write 32位变量 var1

而在程序里
xor eax, eax
xchg eax, var1
必须这样获取和更新 var1,

而总线上,内存只有读写2种命令
所以我担心在执行 xchg半中央时 dma write产生了,这就会
造成var1的某些位丢失.

请问这里的大老们,CPU会不会保证 xchg指令执行期间 内存总线
一直被cpu 占着,而不会被抢走?

谢谢!!


[编辑 -  8/7/04 by  yebear]
boly81
驱动小牛
驱动小牛
  • 注册日期2004-06-25
  • 最后登录2012-06-08
  • 粉丝0
  • 关注0
  • 积分490分
  • 威望73点
  • 贡献值0点
  • 好评度49点
  • 原创分0分
  • 专家分0分
沙发#
发布于: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.
yebear
驱动牛犊
驱动牛犊
  • 注册日期2001-05-18
  • 最后登录2013-04-05
  • 粉丝0
  • 关注0
  • 积分9分
  • 威望51点
  • 贡献值0点
  • 好评度18点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2004-08-10 23:41
再请问前面的几位大老:
  LOCK#信号是锁定总线的吗?我看Intel一个文档好像说这个信号是用在多CPU之间互拆的,跟锁定内存总线没什么关系啊。
boly81
驱动小牛
驱动小牛
  • 注册日期2004-06-25
  • 最后登录2012-06-08
  • 粉丝0
  • 关注0
  • 积分490分
  • 威望73点
  • 贡献值0点
  • 好评度49点
  • 原创分0分
  • 专家分0分
地板#
发布于: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]
wowocock
VIP专家组
VIP专家组
  • 注册日期2002-04-08
  • 最后登录2016-01-09
  • 粉丝16
  • 关注2
  • 积分601分
  • 威望1651点
  • 贡献值1点
  • 好评度1227点
  • 原创分1分
  • 专家分0分
地下室#
发布于:2004-08-09 09:03
用CMPXCHG,或CMPXCHG8B。。。。。
或者在指令前用LOCK锁定总线。。。。
花开了,然后又会凋零,星星是璀璨的,可那光芒也会消失。在这样 一瞬间,人降生了,笑者,哭着,战斗,伤害,喜悦,悲伤憎恶,爱。一切都只是刹那间的邂逅,而最后都要归入死亡的永眠
游客

返回顶部