Thread timer-based preemption

This commit is contained in:
Mark
2020-01-30 12:07:15 +02:00
parent 6e9de43a17
commit 603a8064a3
2 changed files with 25 additions and 0 deletions
+21
View File
@@ -17,9 +17,30 @@ _msg0: .string "CPU stopped!\n"
amd64_irq0:
cli
// Push caller-saved registers so it appears as if a thread just called yield()
pushq %r11
pushq %r10
pushq %r9
pushq %r8
pushq %rcx
pushq %rdx
pushq %rsi
pushq %rdi
pushq %rax
irq_eoi_lapic 0
call yield
popq %rax
popq %rdi
popq %rsi
popq %rdx
popq %rcx
popq %r8
popq %r9
popq %r10
popq %r11
iretq
amd64_irq2_counting:
+4
View File
@@ -1,4 +1,6 @@
#include "sys/amd64/mm/phys.h"
#include "sys/amd64/hw/irq.h"
#include "sys/amd64/hw/idt.h"
#include "sys/assert.h"
#include "sys/thread.h"
#include "sys/mm.h"
@@ -164,5 +166,7 @@ void sched_init(void) {
}
void sched_enter(void) {
extern void amd64_irq0(void);
amd64_idt_set(0, 32, (uintptr_t) amd64_irq0, 0x08, IDT_FLG_P | IDT_FLG_R0 | IDT_FLG_INT32);
context_switch_first(&sched_threads[0]);
}