summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-31 18:40:08 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-31 18:40:08 +0200
commite138ba093d5e1acbad0587aee38f9c09415d24ca (patch)
treedd004919748c04b7b433d46f30178b543cb47e3d /src
parent4d9459b1580cf1667a98dfd1273b926a5a9706c9 (diff)
downloadTCE-e138ba093d5e1acbad0587aee38f9c09415d24ca.tar.gz
TCE-e138ba093d5e1acbad0587aee38f9c09415d24ca.zip
Minor scheduling change.HEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/kernel/task/sched.cpp10
-rw-r--r--src/kernel/task/sched.h7
-rw-r--r--src/kernel/task/task.cpp6
3 files changed, 13 insertions, 10 deletions
diff --git a/src/kernel/task/sched.cpp b/src/kernel/task/sched.cpp
index c17f271..5b3f007 100644
--- a/src/kernel/task/sched.cpp
+++ b/src/kernel/task/sched.cpp
@@ -3,10 +3,6 @@
#include <mem/mem.h>
#include <ui/vt.h>
-// Lower priority numbers have high priority. Priorities must start at 0.
-#define PRIORITIES 3 // we have 3 priority levels
-#define PRIORITY(t) (t->process->privilege) //get priority for a thread
-
extern thread *idle_thread;
static thread *queue[PRIORITIES] = {0}, *last[PRIORITIES] = {0};
@@ -34,9 +30,11 @@ static thread *sched_dequeueFrom(int qid) {
}
/* Used by task.c. Enqueus a thread in the corresponding priority queue. */
-void sched_enqueue(thread *t) {
+void sched_enqueue(thread *t, int priority) {
if (t == idle_thread) return;
- sched_enqueueIn(t, PRIORITY(t));
+ if (priority >= PRIORITIES) priority = PRIORITIES - 1;
+ if (priority < 0) return;
+ sched_enqueueIn(t, priority);
}
/* Used by task.c. Pops a thread from the lowest priority non-empty queue. */
diff --git a/src/kernel/task/sched.h b/src/kernel/task/sched.h
index 1432b02..590a810 100644
--- a/src/kernel/task/sched.h
+++ b/src/kernel/task/sched.h
@@ -3,7 +3,12 @@
#include "task.h"
-void sched_enqueue(thread *t);
+#define PRIORITIES 3 // we have 3 priority levels
+#define TP_LOW 2
+#define TP_MED 1
+#define TP_HIGH 0
+
+void sched_enqueue(thread *t, int priority);
void sched_remove(thread *t);
thread *sched_dequeue();
diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp
index ad9ce50..46fb4d4 100644
--- a/src/kernel/task/task.cpp
+++ b/src/kernel/task/task.cpp
@@ -81,7 +81,7 @@ void schedule() {
current_thread->esp = esp;
current_thread->ebp = ebp;
current_thread->eip = eip;
- if (current_thread->state == TS_RUNNING) sched_enqueue(current_thread);
+ if (current_thread->state == TS_RUNNING) sched_enqueue(current_thread, TP_LOW);
}
current_thread = sched_dequeue();
@@ -137,7 +137,7 @@ void thread_goInactive() {
void thread::wakeUp() {
if (state == TS_WAKEWAIT) {
state = TS_RUNNING;
- sched_enqueue(this);
+ sched_enqueue(this, TP_HIGH);
}
}
@@ -269,7 +269,7 @@ thread::thread(class process *proc, thread_entry entry_point, void *data, void *
proc->threads = this;
state = TS_RUNNING;
- sched_enqueue(this);
+ sched_enqueue(this, TP_MED);
}
/* Creates a new process. Creates a struct process and fills it up. */