Wait for interrupts on last nonsleeping process exit

This commit is contained in:
pjht 2024-09-20 16:10:25 -05:00
parent 01187de0cf
commit 499de08b62
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -289,6 +289,7 @@ impl Tasking {
pub fn exit(&self) -> ! {
let next_process_pid = self.ready_to_run.lock().pop_front();
if let Some(next_process_pid) = next_process_pid {
self.wfi_loop.store(false, Ordering::Relaxed);
#[warn(clippy::indexing_slicing, reason = "FIXME(?)")]
let mut processes = self.processes.write();
if let Some(current_pid) = *self.current_pid.read() {
@ -312,9 +313,11 @@ impl Tasking {
switch_to_asm_exit(kernel_esp);
unreachable!()
} else {
println!("Last non-sleeping process exited, exiting QEMU");
self.print_stats();
qemu_exit::exit_qemu();
//println!("Last non-sleeping process exited, exiting QEMU");
self.wfi_loop.store(true, Ordering::Relaxed);
x86_64::instructions::interrupts::enable_and_hlt();
x86_64::instructions::interrupts::disable();
self.exit();
}
}