diff --git a/src/interrupt/irq.s b/src/interrupt/irq.s index 538ef2f..6575edd 100644 --- a/src/interrupt/irq.s +++ b/src/interrupt/irq.s @@ -38,6 +38,10 @@ irq_common_stub: iret irq0: + push eax + mov eax, [esp + 4] + mov [eip_backup], eax + pop eax push 0 push 32 jmp irq_common_stub diff --git a/src/multitasking/scheduler.c b/src/multitasking/scheduler.c index b72a529..1ee506e 100644 --- a/src/multitasking/scheduler.c +++ b/src/multitasking/scheduler.c @@ -1,11 +1,13 @@ #include "kprintf.h" #include "task.h" +#include "time.h" struct task *current_task; void scheduler(void) { kprintf("camille mon bebou\n"); + sleep(1000); if (!current_task) return; struct task *it = current_task; diff --git a/src/multitasking/switch_to_task.s b/src/multitasking/switch_to_task.s index cb59b7d..8310729 100644 --- a/src/multitasking/switch_to_task.s +++ b/src/multitasking/switch_to_task.s @@ -34,4 +34,6 @@ switch_to_task: pop ebp pop ebx - ret // this will also change eip to the next task's instructions + push [eip_backup] + + iretd // this will also change eip to the next task's instructions diff --git a/src/multitasking/task.c b/src/multitasking/task.c index 371127e..ff5ba06 100644 --- a/src/multitasking/task.c +++ b/src/multitasking/task.c @@ -3,10 +3,7 @@ #include "kpanic.h" #include "memory.h" -static void set_eip(void (*fn)(void), struct task *task) -{ - // TODO or not TODO -} +uint32_t eip_backup; static struct task *create_task(uint8_t owner_id) { @@ -30,11 +27,14 @@ void exec_fn(void (*fn)(void)) if (!new_task) kpanic("failed to create new task"); new_task->status = RUN; + new_task->eip = (uint32_t *)fn; new_task->next = current_task; - new_task->prev = current_task->prev; - current_task->prev = new_task; + new_task->prev = new_task; + if (current_task) { + new_task->prev = current_task->prev; + current_task->prev = new_task; + } current_task = new_task; - set_eip(fn, new_task); } /*