x86 equivalent for LWARX and STWCX

前端 未结 6 1664
天命终不由人
天命终不由人 2020-12-17 22:07

I\'m looking for an equivalent of LWARX and STWCX (as found on the PowerPC processors) or a way to implement similar functionality on the x86 platform. Also, where would be

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-17 22:25

    What you are trying to do will not work the way you expect. What you implemented above can be done with the InterlockedIncrement function (Win32 function; assembly: XADD).

    The reason that your code does not do what you think it does is that another thread can still change the value between the second read of *ptr and stwcx without invalidating the stwcx.

提交回复
热议问题