vbos/init/lock.c
Michael Shaw 8e6d0d4fbc kernel: add support for basic type spinlock_t
A spinlock is the most basic type of lock. It will attempt to acquire,
and upon failure, will continue attempting indefinitely until it is
successful.
2023-05-27 01:44:33 -04:00

13 lines
211 B
C

#include <kernel/common.h>
#include <kernel/lock.h>
void spinlock_acquire(spinlock_t *lock)
{
while (atomic_cmpxchg(lock, 0, 1))
;
}
void spinlock_release(spinlock_t *lock)
{
atomic_cmpxchg(lock, 1, 0);
}