a cow based x86_64 operating system, using limine and stivale2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
566 B

[global _spinlock_init]
[global _spinlock_acquire]
[global _spinlock_release]
; stolen from https://wiki.osdev.org/Spinlock#Improved_Lock
test dword [rdi],1 ;Is the lock free?
jnz spin_wait ;no, wait
lock bts dword [rdi],0 ;Attempt to acquire the lock (in case lock is uncontended)
jc spin_wait ;Spin if locked ( organize code such that conditional jumps are typically not taken )
ret ;Lock obtained
mov dword [rdi], 0