Support signal mechanism for ch8(only works on signal-thread apps)
This commit is contained in:
parent
59f13cb536
commit
26bc01f3bc
17 changed files with 235 additions and 17 deletions
|
@ -3,8 +3,8 @@ mod context;
|
|||
use crate::config::TRAMPOLINE;
|
||||
use crate::syscall::syscall;
|
||||
use crate::task::{
|
||||
current_trap_cx, current_trap_cx_user_va, current_user_token, exit_current_and_run_next,
|
||||
suspend_current_and_run_next,
|
||||
check_signals_of_current, current_add_signal, current_trap_cx, current_trap_cx_user_va,
|
||||
current_user_token, exit_current_and_run_next, suspend_current_and_run_next, SignalFlags,
|
||||
};
|
||||
use crate::timer::{check_timer, set_next_trigger};
|
||||
use core::arch::{asm, global_asm};
|
||||
|
@ -60,19 +60,18 @@ pub fn trap_handler() -> ! {
|
|||
| Trap::Exception(Exception::InstructionPageFault)
|
||||
| Trap::Exception(Exception::LoadFault)
|
||||
| Trap::Exception(Exception::LoadPageFault) => {
|
||||
/*
|
||||
println!(
|
||||
"[kernel] {:?} in application, bad addr = {:#x}, bad instruction = {:#x}, kernel killed it.",
|
||||
scause.cause(),
|
||||
stval,
|
||||
current_trap_cx().sepc,
|
||||
);
|
||||
// page fault exit code
|
||||
exit_current_and_run_next(-2);
|
||||
*/
|
||||
current_add_signal(SignalFlags::SIGSEGV);
|
||||
}
|
||||
Trap::Exception(Exception::IllegalInstruction) => {
|
||||
println!("[kernel] IllegalInstruction in application, kernel killed it.");
|
||||
// illegal instruction exit code
|
||||
exit_current_and_run_next(-3);
|
||||
current_add_signal(SignalFlags::SIGILL);
|
||||
}
|
||||
Trap::Interrupt(Interrupt::SupervisorTimer) => {
|
||||
set_next_trigger();
|
||||
|
@ -87,6 +86,11 @@ pub fn trap_handler() -> ! {
|
|||
);
|
||||
}
|
||||
}
|
||||
// check signals
|
||||
if let Some((errno, msg)) = check_signals_of_current() {
|
||||
println!("[kernel] {}", msg);
|
||||
exit_current_and_run_next(errno);
|
||||
}
|
||||
trap_return();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue