Move spinlock to separate folder
This commit is contained in:
21
kernel/spinlock/spinlock.h
Normal file
21
kernel/spinlock/spinlock.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef SPINLOCK_SPINLOCK_H_
|
||||
#define SPINLOCK_SPINLOCK_H_
|
||||
|
||||
#include <stdatomic.h>
|
||||
#include <stdint.h>
|
||||
#include "hal/hal.h"
|
||||
|
||||
typedef struct { atomic_bool lock; } SpinLock;
|
||||
|
||||
// Spin more efficiently - cpu dependant
|
||||
#if defined(__x86_64__)
|
||||
# define SPINLOCK_HINT() asm volatile("pause")
|
||||
#else
|
||||
# define SPINLOCK_HINT()
|
||||
#endif
|
||||
|
||||
void spinlock_init(SpinLock *sl);
|
||||
void spinlock_acquire(SpinLock *sl);
|
||||
void spinlock_release(SpinLock *sl);
|
||||
|
||||
#endif // SPINLOCK_SPINLOCK_H_
|
Reference in New Issue
Block a user