Kernel: Prevent deadlocks when panicking

This commit is contained in:
apio 2022-11-01 11:11:20 +01:00
parent 06c7bbac0d
commit b4914c26fe

View File

@ -1,9 +1,12 @@
use core::panic::PanicInfo; use core::panic::PanicInfo;
use crate::println; use crate::try_println;
use crate::arch::io::SERIAL;
use crate::arch::cpu;
#[panic_handler] #[panic_handler]
fn panic(info: &PanicInfo) -> ! { fn panic(info: &PanicInfo) -> ! {
println!("Kernel {}", info); unsafe { SERIAL.force_unlock(); } // since we're panicking, this is not relevant anymore.
loop {} try_println!("Kernel {}", info); // we probably should succeed, unless another CPU locked the serial port just after we unlocked it but before try_println attempts to lock it.
cpu::halt();
} }