summaryrefslogtreecommitdiff
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index efbb80a..529db61 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1,6 +1,9 @@
#include <asm/system.h>
+#include <kernel/con.h>
+#include <kernel/kernel.h>
#include <kernel/memory.h>
#include <kernel/sched.h>
+#include <signal.h>
#include <string.h>
#include <sys/types.h>
@@ -144,14 +147,12 @@ struct task_struct *create_proc(void *bin, size_t len) {
/* load in the user binary */
memcpy(USRSTART, bin, len);
- /*
- * here we initialize the task struct.
- * currently, we only setup state information
- * necessary to begin execution.
- */
+ /* initialize the task struct */
memset(task, 0, sizeof(struct task_struct));
task->pid = nextpid;
task->state = TSTATE_RUNNING;
+
+ /* initialize the task's state */
task->tss.cr3 = (uint32_t) pdir;
task->tss.cs = 0x1B;
task->tss.ds = 0x23;
@@ -185,7 +186,6 @@ void sched_init(void) {
create_proc(&_usrbin_start, (size_t) &_usrbin_size);
create_proc(&_usrbin_start, (size_t) &_usrbin_size);
- create_proc(&_usrbin_start, (size_t) &_usrbin_size);
switch_to(0, &tasks[0]);
}
@@ -198,11 +198,12 @@ void reschedule(void) {
return;
n = ctaskn;
- for(i = 0; i < NRTASKS; i++) {
+ while(1) {
n = (n + 1) % NRTASKS;
if(tasks[n].pid && tasks[n].state == TSTATE_RUNNING)
break;
}
+
switch_to(n, &tasks[n]);
}
@@ -217,3 +218,7 @@ void wake_up(struct task_struct **task) {
(*task)->state = TSTATE_RUNNING;
*task = NULL;
}
+
+void sighandler_default(uint32_t sig) {
+ printk("[kernel] Handling signal 0x%02x for PID 0x%04x\n", sig, ctask->pid);
+}