summaryrefslogtreecommitdiff
path: root/src/kernel/task/sched.c
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-08-10 21:28:57 +0200
committerAlexis211 <alexis211@gmail.com>2010-08-10 21:28:57 +0200
commit73db7abddad13d41e67f41431c4ad92c4f364d3c (patch)
tree0e61b117e9f8b64e4d41220ba2fe25c1d3f83da5 /src/kernel/task/sched.c
parente7f5de73e8b3fe792a17c34a6c0bb85a84b0f50e (diff)
downloadTCE-73db7abddad13d41e67f41431c4ad92c4f364d3c.tar.gz
TCE-73db7abddad13d41e67f41431c4ad92c4f364d3c.zip
Now using a simple Round Robin scheduler.
Diffstat (limited to 'src/kernel/task/sched.c')
-rw-r--r--src/kernel/task/sched.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/kernel/task/sched.c b/src/kernel/task/sched.c
new file mode 100644
index 0000000..d2a4c5b
--- /dev/null
+++ b/src/kernel/task/sched.c
@@ -0,0 +1,24 @@
+#include "sched.h"
+#include <core/sys.h>
+#include <mem/mem.h>
+
+static struct thread *queue = 0, *last = 0;
+
+void sched_enqueue(struct thread *t) {
+ t->queue_next = 0;
+ if (queue == 0) {
+ queue = last = t;
+ } else {
+ last->queue_next = t;
+ last = t;
+ }
+}
+
+struct thread *sched_dequeue() {
+ if (queue == 0) return 0;
+ struct thread *it = queue;
+ ASSERT((it->queue_next == 0 && it == last) || it != last);
+ queue = it->queue_next;
+ if (queue == 0) last = 0;
+ return it;
+}