aboutsummaryrefslogtreecommitdiff
path: root/kernel/task/include/task/lock.h
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2014-03-17 16:50:15 +0100
committerJakob Odersky <jodersky@gmail.com>2014-03-17 16:53:46 +0100
commit2500120f64db83fc682f38a83f7f9e03ed8a5123 (patch)
tree4b9c2086c9d5dde0a89b4968db05e3b52aaa1e65 /kernel/task/include/task/lock.h
parent01c10b2eadbcd09b6ac34ab80cac1b65c302152e (diff)
downloadmux-2500120f64db83fc682f38a83f7f9e03ed8a5123.tar.gz
mux-2500120f64db83fc682f38a83f7f9e03ed8a5123.tar.bz2
mux-2500120f64db83fc682f38a83f7f9e03ed8a5123.zip
add spin-locks
Diffstat (limited to 'kernel/task/include/task/lock.h')
-rw-r--r--kernel/task/include/task/lock.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/kernel/task/include/task/lock.h b/kernel/task/include/task/lock.h
index eaa661c..47246b2 100644
--- a/kernel/task/include/task/lock.h
+++ b/kernel/task/include/task/lock.h
@@ -1,20 +1,21 @@
#ifndef LOCK_H
#define LOCK_H
-#include "task/shed.h"
+#include "task/sched.h"
-typedef char spin_lock_t;
+typedef volatile char spin_lock_t;
#define SPIN_LOCK_UNLOCKED 0
+#define SPIN_LOCK_LOCKED 0
-static inline void spin_lock(struct spin_lock_t* lock) {
+static inline void spin_lock(spin_lock_t* lock) {
while(*lock != SPIN_LOCK_UNLOCKED) {yield();};
cli();
- *lock = 1;
+ *lock = SPIN_LOCK_LOCKED;
sei();
}
-static inline void spin_unlock(struct spin_lock_t* lock) {
+static inline void spin_unlock(spin_lock_t* lock) {
cli();
*lock = SPIN_LOCK_UNLOCKED;
sei();