diff options
author | nthnluu <nate1299@me.com> | 2024-01-28 21:20:27 -0500 |
---|---|---|
committer | nthnluu <nate1299@me.com> | 2024-01-28 21:20:27 -0500 |
commit | c63f340d90800895f007de64b7d2d14624263331 (patch) | |
tree | 2c0849fa597dd6da831c8707b6f2603403778d7b /kernel/proc/spinlock.c |
Created student weenix repository
Diffstat (limited to 'kernel/proc/spinlock.c')
-rw-r--r-- | kernel/proc/spinlock.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/proc/spinlock.c b/kernel/proc/spinlock.c new file mode 100644 index 0000000..bf89b8e --- /dev/null +++ b/kernel/proc/spinlock.c @@ -0,0 +1,21 @@ +#include "globals.h" +#include "main/apic.h" + +void spinlock_init(spinlock_t *lock) { lock->s_locked = 0; } + +inline void spinlock_lock(spinlock_t *lock) +{ +// __sync_bool_compare_and_swap is a GCC intrinsic for atomic compare-and-swap +// If lock->locked is 0, then it is set to 1 and __sync_bool_compare_and_swap +// returns true Otherwise, lock->locked is left at 1 and +// __sync_bool_compare_and_swap returns false +} + +inline void spinlock_unlock(spinlock_t *lock) +{ +} + +inline long spinlock_ownslock(spinlock_t *lock) +{ + return 1; +} |