Thread timer-based preemption
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user