Increase kernel heap size to fit more ELFs, improve scheduler by

removing O(n) operations (ready and sleep queues now), caching timer
ticks per irq on init_interrupts aarch64, only saving context when
switching, add kill syscall and use it for exit, only push input to
init, fix accidental REL_X events drop with virtio, fix the possibility
of not having a process to switch to by either staying, switching or
idling, improve scheduler by removing double locking and splitting code
to multiple functions, do not switch every IRQ but only 100 IRQs,
improve rust app building, move x86_64 kernel fb so it doesn't hit heap,
update submodules
This commit is contained in:
csd4ni3l
2026-05-30 19:10:26 +02:00
parent 6b4b53729b
commit f943cf5426
22 changed files with 371 additions and 181 deletions
+25
View File
@@ -3,8 +3,11 @@ use core::arch::asm;
use x86_64::instructions::tlb::flush_all;
use crate::{
arch::arch::safe_lock,
arch::x86_64::gdt::{GDT, TSS_MUTEX},
task::context::UserContext,
task::process::ProcessState,
task::scheduler::{SCHEDULER, current_pid},
};
const IA32_EFER: u32 = 0xC0000080;
@@ -129,6 +132,8 @@ unsafe extern "C" fn syscall_entry() {
call ctx_save
mov rsp, rbx
sti
mov rdi, qword ptr [rbx + 112]
mov rsi, qword ptr [rbx + 72]
mov rdx, qword ptr [rbx + 64]
@@ -149,6 +154,9 @@ unsafe extern "C" fn syscall_entry() {
call ctx_save
mov rsp, rbx
mov rdi, rbx
call syscall_yield_check
mov rax, qword ptr [rsp + 128]
mov qword ptr [rsp + 96], rax
mov rax, qword ptr [rsp + 136]
@@ -170,6 +178,7 @@ unsafe extern "C" fn syscall_entry() {
mov r13, qword ptr [rsp + 16]
mov r14, qword ptr [rsp + 8]
mov r15, qword ptr [rsp + 0]
cli
mov rsp, qword ptr gs:[0]
swapgs
sysretq
@@ -179,6 +188,22 @@ unsafe extern "C" fn syscall_entry() {
);
}
#[unsafe(no_mangle)]
unsafe extern "C" fn syscall_yield_check(_ctx: *mut UserContext) {
if let Some(pid) = current_pid() {
let needs_yield = {
let guard = safe_lock(|| SCHEDULER.lock());
guard
.processes
.get(&pid)
.map_or(false, |p| !matches!(p.state, ProcessState::Running))
};
if needs_yield {
SCHEDULER.switch_next(true);
}
}
}
#[unsafe(naked)]
#[unsafe(no_mangle)]
pub unsafe fn run_next(ctx: *const UserContext, user_rsp: u64, user_cs: u64, user_ss: u64) {