Add a basic scheduler with threads #18

Merged
apio merged 19 commits from threads into restart 2022-12-07 16:11:59 +00:00
2 changed files with 9 additions and 6 deletions
Showing only changes of commit c561b0b310 - Show all commits

View File

@ -48,12 +48,7 @@ load_tr:
ltr ax
ret
global switch_task
switch_task:
cli
.loop:
hlt
jmp .loop
extern switch_task
global kernel_yield
kernel_yield:

View File

@ -3,6 +3,7 @@
#include "arch/Timer.h"
#include "arch/x86_64/CPU.h"
#include "arch/x86_64/IO.h"
#include "thread/Scheduler.h"
#include <cpuid.h>
#include <luna/Check.h>
#include <luna/Result.h>
@ -336,6 +337,7 @@ extern "C" void arch_interrupt_entry(Registers* regs)
else if (regs->isr == 32)
{
Timer::tick();
if (should_invoke_scheduler()) Scheduler::invoke(regs);
pic_eoi(regs);
}
else
@ -442,4 +444,10 @@ namespace CPU
{
task_state_segment.rsp[0] = top;
}
}
// called by kernel_yield
extern "C" void switch_task(Registers* regs)
{
Scheduler::switch_task(regs);
}