All checks were successful
Build documentation / build-and-deploy (push) Successful in 21s
18 lines
413 B
C
18 lines
413 B
C
#include <libk/std.h>
|
|
#include <sync/spin_lock.h>
|
|
#include <sys/irq.h>
|
|
#include <sys/spin_lock.h>
|
|
|
|
void spin_lock (spin_lock_t* sl, spin_lock_ctx_t* ctx) {
|
|
irq_save (ctx);
|
|
|
|
while (atomic_flag_test_and_set_explicit (sl, memory_order_acquire))
|
|
spin_lock_relax ();
|
|
}
|
|
|
|
void spin_unlock (spin_lock_t* sl, spin_lock_ctx_t* ctx) {
|
|
atomic_flag_clear_explicit (sl, memory_order_release);
|
|
|
|
irq_restore (ctx);
|
|
}
|