feat(kernel): add Exit and ExitThread syscalls with process cleanup

This commit is contained in:
2026-10-18 00:16:38 +02:00
parent d0a0ba788f
commit 74b296a2bf
4 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
use super::*;
use crate::{SyscallOutcome, SyscallResult};
use domain::syscall::Syscall;
#[test]
fn exit_thread_terminates_caller() {
let (mut k, _) = kernel_with_process();
let outcome = k.handle_syscall(Syscall::ExitThread);
assert!(matches!(outcome, SyscallOutcome::TerminateCaller));
}
#[test]
fn exit_terminates_process_and_all_threads() {
let (mut k, _) = kernel_with_process();
let outcome = k.handle_syscall(Syscall::Exit);
assert!(matches!(outcome, SyscallOutcome::TerminateCaller));
}
#[test]
fn exit_thread_last_thread_destroys_process() {
let (mut k, pid) = kernel_with_process();
k.handle_syscall(Syscall::ExitThread);
// Process should be gone since it had only one thread
assert!(k.process_exists(pid) == false);
}

View File

@@ -1,3 +1,4 @@
mod exit;
mod simple;
use domain::memory::page_pool::PagePool;