Luna/kernel/src/thread/Spinlock.asm

20 lines
353 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:
mov rax, [rdi]
ret