23 lines
No EOL
422 B
C
23 lines
No EOL
422 B
C
#include <error.h>
|
|
#include <stdatomic.h>
|
|
#include <stdbool.h>
|
|
|
|
#ifndef SPINLOCK_H
|
|
#define SPINLOCK_H
|
|
|
|
struct mutex {
|
|
atomic_flag lock;
|
|
bool locked;
|
|
struct thread *holder;
|
|
};
|
|
|
|
void acquire_spinlock(atomic_flag *lock);
|
|
void free_spinlock(atomic_flag *lock);
|
|
|
|
struct mutex *init_mutex();
|
|
kstatus acquire_mutex(struct mutex *mut);
|
|
void free_mutex(struct mutex *mut);
|
|
kstatus try_mutex(struct mutex *mut);
|
|
|
|
|
|
#endif |