Schedule inside of systick_irq
This commit is contained in:
@@ -239,12 +239,12 @@ static uint32_t lapic_calibrate (uint32_t us) {
|
||||
|
||||
lapic_write (LAPIC_DCR, DIVIDER_VALUE);
|
||||
|
||||
lapic_write (LAPIC_LVTTR, INTR_SCHED_PREEMPT_TIMER | (1 << 16));
|
||||
lapic_write (LAPIC_LVTTR, INTR_SYSTICK | (1 << 16));
|
||||
lapic_write (LAPIC_TIMICT, 0xFFFFFFFF);
|
||||
|
||||
sleep_micro (us);
|
||||
|
||||
lapic_write (LAPIC_LVTTR, INTR_SCHED_PREEMPT_TIMER | (0 << 16));
|
||||
lapic_write (LAPIC_LVTTR, INTR_SYSTICK | (0 << 16));
|
||||
uint32_t ticks = 0xFFFFFFFF - lapic_read (LAPIC_TIMCCT);
|
||||
DEBUG ("timer ticks = %u\n", ticks);
|
||||
|
||||
@@ -254,14 +254,14 @@ static uint32_t lapic_calibrate (uint32_t us) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Starts a Local APIC, configures LVT timer to send interrupts at SCHED_PREEMPT_TIMER.
|
||||
* Starts a Local APIC, configures LVT timer to send interrupts at SYSTICK.
|
||||
*
|
||||
* ticks - Initial tick count
|
||||
*/
|
||||
static void lapic_start (uint32_t ticks) {
|
||||
lapic_write (LAPIC_DCR, DIVIDER_VALUE);
|
||||
lapic_write (LAPIC_TIMICT, ticks);
|
||||
lapic_write (LAPIC_LVTTR, INTR_SCHED_PREEMPT_TIMER | (1 << 17));
|
||||
lapic_write (LAPIC_LVTTR, INTR_SYSTICK | (1 << 17));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <amd64/msr-index.h>
|
||||
#include <amd64/msr.h>
|
||||
#include <amd64/sse.h>
|
||||
#include <amd64/systick.h>
|
||||
#include <aux/compiler.h>
|
||||
#include <device/device.h>
|
||||
#include <device/storage/partitions.h>
|
||||
@@ -62,7 +63,7 @@ void bootmain (void) {
|
||||
|
||||
bsp_cpu->kproc = kproc_create ();
|
||||
|
||||
lapic_init (5000);
|
||||
lapic_init (1000);
|
||||
|
||||
__asm__ volatile ("sti");
|
||||
|
||||
@@ -78,7 +79,7 @@ void bootmain (void) {
|
||||
struct device* temp0 = device_find ("temp0");
|
||||
vfs_create_volume (thiscpu->kproc, &rctx, "temp", FS_FAT16, temp0, true);
|
||||
|
||||
irq_attach (&proc_irq_sched, NULL, INTR_SCHED_PREEMPT_TIMER);
|
||||
irq_attach (&systick_irq, NULL, INTR_SYSTICK);
|
||||
irq_attach (&proc_irq_sched, NULL, INTR_CPU_REQUEST_SCHED);
|
||||
|
||||
smp_init ();
|
||||
|
||||
@@ -126,7 +126,7 @@ static void idt_init (void) {
|
||||
IDT_ENTRY (40, 2); IDT_ENTRY (41, 2); IDT_ENTRY (42, 2); IDT_ENTRY (43, 2);
|
||||
IDT_ENTRY (44, 2); IDT_ENTRY (45, 2); IDT_ENTRY (46, 2); IDT_ENTRY (47, 2);
|
||||
|
||||
IDT_ENTRY (INTR_SCHED_PREEMPT_TIMER, 2);
|
||||
IDT_ENTRY (INTR_SYSTICK, 2);
|
||||
IDT_ENTRY (INTR_CPU_REQUEST_SCHED, 2);
|
||||
IDT_ENTRY (INTR_CPU_SPURIOUS, 2);
|
||||
/* clang-format on */
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#define INTR_IDE_DRIVE_SCND 34
|
||||
#define INTR_XHCI 35
|
||||
|
||||
#define INTR_SCHED_PREEMPT_TIMER 80
|
||||
#define INTR_CPU_REQUEST_SCHED 82
|
||||
#define INTR_CPU_SPURIOUS 255
|
||||
#define INTR_SYSTICK 80
|
||||
#define INTR_CPU_REQUEST_SCHED 82
|
||||
#define INTR_CPU_SPURIOUS 255
|
||||
|
||||
#endif // _KERNEL_AMD64_INTR_DEFS_H
|
||||
|
||||
@@ -91,6 +91,6 @@ make_intr_stub(no_err, 45)
|
||||
make_intr_stub(no_err, 46)
|
||||
make_intr_stub(no_err, 47)
|
||||
|
||||
make_intr_stub(no_err, INTR_SCHED_PREEMPT_TIMER)
|
||||
make_intr_stub(no_err, INTR_SYSTICK)
|
||||
make_intr_stub(no_err, INTR_CPU_REQUEST_SCHED)
|
||||
make_intr_stub(no_err, INTR_CPU_SPURIOUS)
|
||||
|
||||
@@ -100,7 +100,7 @@ static void smp_bootstrap (struct limine_mp_info* mp_info) {
|
||||
syscall_init ();
|
||||
sse_enable ();
|
||||
|
||||
lapic_init (5000);
|
||||
lapic_init (1000);
|
||||
|
||||
DEBUG ("CPU %u is online!\n", thiscpu->id);
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ c += amd64/bootmain.c \
|
||||
amd64/proc.c \
|
||||
amd64/syscall.c \
|
||||
amd64/gdt.c \
|
||||
amd64/stall.c
|
||||
amd64/stall.c \
|
||||
amd64/systick.c
|
||||
|
||||
S += amd64/intr_stub.S \
|
||||
amd64/spin.S \
|
||||
@@ -41,4 +42,5 @@ o += amd64/bootmain.o \
|
||||
amd64/syscallentry.o \
|
||||
amd64/gdt.o \
|
||||
amd64/sse.o \
|
||||
amd64/stall.o
|
||||
amd64/stall.o \
|
||||
amd64/systick.o
|
||||
|
||||
12
kernel/amd64/systick.c
Normal file
12
kernel/amd64/systick.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <libk/std.h>
|
||||
#include <proc/reschedule.h>
|
||||
#include <sys/smp.h>
|
||||
|
||||
static uint32_t systicks = 0;
|
||||
|
||||
void systick_irq (void* arg, void* regs, bool user, struct reschedule_ctx* rctx) {
|
||||
systicks++;
|
||||
|
||||
if (systicks % 5 == 0)
|
||||
rctx_insert_cpu (rctx, thiscpu);
|
||||
}
|
||||
9
kernel/amd64/systick.h
Normal file
9
kernel/amd64/systick.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _KERNEL_AMD64_SYSTICK_H
|
||||
#define _KERNEL_AMD64_SYSTICK_H
|
||||
|
||||
#include <libk/std.h>
|
||||
#include <proc/reschedule.h>
|
||||
|
||||
void systick_irq (void* arg, void* regs, bool user, struct reschedule_ctx* rctx);
|
||||
|
||||
#endif // // _KERNEL_AMD64_SYSTICK_H
|
||||
Reference in New Issue
Block a user