aboutsummaryrefslogtreecommitdiff
path: root/kernel/task/include/task/lock.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/task/include/task/lock.h')
-rw-r--r--kernel/task/include/task/lock.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel/task/include/task/lock.h b/kernel/task/include/task/lock.h
new file mode 100644
index 0000000..bfb7994
--- /dev/null
+++ b/kernel/task/include/task/lock.h
@@ -0,0 +1,19 @@
+#ifndef LOCK_H
+#define LOCK_H
+
+#include "task/shed.h"
+
+typedef char spin_lock_t;
+
+#define SPIN_LOCK_UNLOCKED 0
+
+static inline void spin_lock(struct spin_lock_t* lock) {
+ while(*lock != SPIN_LOCK_UNLOCKED) {yield();};
+ *lock = 1;
+}
+
+static inline void spin_unlock(struct spin_lock_t* lock) {
+ *lock = SPIN_LOCK_UNLOCKED;
+}
+
+#endif \ No newline at end of file