我正在使用以下x86-64
程序集来获取和释放互斥锁:
.data
align 16
mtx:
dd 0
.code
acquire_mutex PROC
lbl_retry:
lock bts dword ptr [mtx], 1
jnc lbl_acquired
pause
jmp lbl_retry
lbl_acquired:
ret
acquire_mutex ENDP
release_mutex PROC
mov dword ptr [mtx], 0
ret
release_mutex ENDP
我的问题是。我是否可以正确释放互斥锁?还是我需要这样的lock
?
release_mutex PROC
lock and dword ptr [mtx], 0
ret
release_mutex ENDP