summaryrefslogtreecommitdiff
path: root/src/kernel/task/sched.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/task/sched.cpp')
-rw-r--r--src/kernel/task/sched.cpp10
1 files changed, 4 insertions, 6 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. */