summaryrefslogtreecommitdiff
path: root/src/kernel/task/sched.cpp
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-20 16:34:27 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-20 16:34:27 +0200
commit7fde5e61bc7047433bfc1f47229b72d0ccd302e7 (patch)
tree7228e9008ecffa85100ac31ee5063edc62abf41e /src/kernel/task/sched.cpp
parentc57a919d019606c7d83fea574159f542e431c199 (diff)
downloadTCE-7fde5e61bc7047433bfc1f47229b72d0ccd302e7.tar.gz
TCE-7fde5e61bc7047433bfc1f47229b72d0ccd302e7.zip
Correected some nasty tasking bugs. Still not perfect.
Diffstat (limited to 'src/kernel/task/sched.cpp')
-rw-r--r--src/kernel/task/sched.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/kernel/task/sched.cpp b/src/kernel/task/sched.cpp
index 36f6783..c17f271 100644
--- a/src/kernel/task/sched.cpp
+++ b/src/kernel/task/sched.cpp
@@ -26,9 +26,10 @@ static void sched_enqueueIn(thread *t, int qid) {
static thread *sched_dequeueFrom(int qid) {
if (queue[qid] == 0) return 0;
thread *it = queue[qid];
- ASSERT((it->queue_next == 0 && it == last[qid]) || it != last[qid]);
+ ASSERT((it->queue_next == 0 && it == last[qid]) || (it->queue_next != 0 && it != last[qid]));
queue[qid] = it->queue_next;
if (queue[qid] == 0) last[qid] = 0;
+ it->queue_next = 0;
return it;
}
@@ -55,11 +56,15 @@ void sched_remove(thread *t) {
for (int i = 0; i < PRIORITIES; i++) {
if (queue[i] == t) {
queue[i] = t->queue_next;
+ ASSERT((t->queue_next == 0 && last[i] == t) || (t->queue_next != 0 && last[i] != t));
+ if (last[i] == t) last[i] = 0;
} else if (queue[i] != 0) {
thread *it = queue[i];
while (it->queue_next != 0) {
if (it->queue_next == t) {
it->queue_next = t->queue_next;
+ ASSERT((t->queue_next == 0 && last[i] == t) || (t->queue_next != 0 && last[i] != t));
+ if (last[i] == t) last[i] = it;
break;
}
it = it->queue_next;