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 ltr ax
ret ret
global switch_task extern switch_task
switch_task:
cli
.loop:
hlt
jmp .loop
global kernel_yield global kernel_yield
kernel_yield: kernel_yield:

View File

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