I'm using the following x86-64
assembly for my functions to acquire and release a mutex:
.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
My question is. Am I releasing the mutex correctly? Or do I need a lock
on it as such?
release_mutex PROC
lock and dword ptr [mtx], 0
ret
release_mutex ENDP