x86_64: Invoke the scheduler every millisecond

This commit is contained in:
apio 2022-12-07 15:04:02 +01:00
parent f97e392f89
commit c561b0b310
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 9 additions and 6 deletions

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
@ -443,3 +445,9 @@ namespace CPU
task_state_segment.rsp[0] = top;
}
}
// called by kernel_yield
extern "C" void switch_task(Registers* regs)
{
Scheduler::switch_task(regs);
}