aboutsummaryrefslogtreecommitdiff
path: root/kernel/task
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/task')
-rw-r--r--kernel/task/include/task/lock.h11
-rw-r--r--kernel/task/sched.c10
2 files changed, 16 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();
diff --git a/kernel/task/sched.c b/kernel/task/sched.c
index 652d562..ceaf9bb 100644
--- a/kernel/task/sched.c
+++ b/kernel/task/sched.c
@@ -35,7 +35,17 @@ void sched_init() {
ret();
}
+
+#include <avr/io.h>
+void toggle_led() {
+ DDRB |= (1 << 7);
+ PORTB ^= (1 << 7);
+}
+
+
+
void schedule() {
+ toggle_led();
if(!list_empty(&ready)) {
current = list_entry(ready.next, struct tcb_t, queue);
list_move_tail(ready.next, &ready);