Why we need lock prefix before CMPXCHG [duplicate]

不问归期 提交于 2019-12-01 18:26:42
  • CMXCHG is truly atomic(asserts a bus lock) on a multiprocessor system only when it is prefixed with LOCK. These days snooping based cache coherence protocols are being used which eliminates the need for the fence(bus lock).
  • Coming to second part of the question(the value would anyways be changed). YES in that case the CMPXCHG instruction fails but nevertheless is still atomic with respect to all the processors.

Bottom line: Lock prefix makes the CMPXCHG a multiprocessor barrier instruction.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!