I was wondering how a spinlock would come into play in terms of locking or unlocking memory data structures. I read the spinlock article and kind of understand how it works. Although, I am curious as to how it does not lock all memory and only target a certain memory address.
Code:
acquireLock:
lock bts [lock],0
jc .spin_with_pause
ret
.spin_with_pause:
pause
test dword [lock],1
jnz .spin_with_pause
jmp acquireLock
releaseLock:
mov dword [lock],0
ret
How does this code know what memory data structure to lock? Please excuse my ignorance.