From 45f420a338ea02225bb8a98c9aca5eed8d6a23ae Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Sun, 2 Jun 2024 00:26:57 +0200 Subject: Initial commit --- kernel/spinlock.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 kernel/spinlock.h (limited to 'kernel/spinlock.h') diff --git a/kernel/spinlock.h b/kernel/spinlock.h new file mode 100644 index 0000000..5e9ac40 --- /dev/null +++ b/kernel/spinlock.h @@ -0,0 +1,15 @@ +#pragma once + +#include "kernel/lib.h" + +struct Spinlock +{ + volatile uint32_t next_ticket; + volatile uint32_t serving; + uint32_t locking; +}; +typedef struct Spinlock Spinlock; + +void spinlock_init(Spinlock* lock); +void spinlock_acquire(Spinlock* lock); +void spinlock_release(Spinlock* lock); -- cgit