26 lines
424 B
NASM
26 lines
424 B
NASM
|
global spinlock_lock_acquire
|
||
|
spinlock_lock_acquire:
|
||
|
lock bts qword [rdi], 0
|
||
|
jc .spin
|
||
|
ret
|
||
|
.spin:
|
||
|
pause
|
||
|
test qword [rdi], 1
|
||
|
jnz .spin
|
||
|
jmp spinlock_lock_acquire
|
||
|
|
||
|
global spinlock_lock_release
|
||
|
spinlock_lock_release:
|
||
|
mov qword [rdi], 0
|
||
|
ret
|
||
|
|
||
|
global spinlock_lock_is_locked
|
||
|
spinlock_lock_is_locked:
|
||
|
cmp qword [rdi], 0
|
||
|
je .free
|
||
|
.locked:
|
||
|
mov rax, 1
|
||
|
ret
|
||
|
.free:
|
||
|
mov rax, 0
|
||
|
ret
|