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,6 +3,7 @@ mod id;
|
|||
mod manager;
|
||||
mod process;
|
||||
mod processor;
|
||||
mod signal;
|
||||
mod switch;
|
||||
mod task;
|
||||
|
||||
|
@ -15,11 +16,12 @@ use switch::__switch;
|
|||
|
||||
pub use context::TaskContext;
|
||||
pub use id::{kstack_alloc, pid_alloc, KernelStack, PidHandle};
|
||||
pub use manager::add_task;
|
||||
pub use manager::{add_task, pid2process, remove_from_pid2process};
|
||||
pub use processor::{
|
||||
current_kstack_top, current_process, current_task, current_trap_cx, current_trap_cx_user_va,
|
||||
current_user_token, run_tasks, schedule, take_current_task,
|
||||
};
|
||||
pub use signal::SignalFlags;
|
||||
pub use task::{TaskControlBlock, TaskStatus};
|
||||
|
||||
pub fn suspend_current_and_run_next() {
|
||||
|
@ -64,6 +66,7 @@ pub fn exit_current_and_run_next(exit_code: i32) {
|
|||
// however, if this is the main thread of current process
|
||||
// the process should terminate at once
|
||||
if tid == 0 {
|
||||
remove_from_pid2process(process.getpid());
|
||||
let mut process_inner = process.inner_exclusive_access();
|
||||
// mark this process as a zombie process
|
||||
process_inner.is_zombie = true;
|
||||
|
@ -111,3 +114,15 @@ lazy_static! {
|
|||
pub fn add_initproc() {
|
||||
let _initproc = INITPROC.clone();
|
||||
}
|
||||
|
||||
pub fn check_signals_of_current() -> Option<(i32, &'static str)> {
|
||||
let process = current_process();
|
||||
let process_inner = process.inner_exclusive_access();
|
||||
process_inner.signals.check_error()
|
||||
}
|
||||
|
||||
pub fn current_add_signal(signal: SignalFlags) {
|
||||
let process = current_process();
|
||||
let mut process_inner = process.inner_exclusive_access();
|
||||
process_inner.signals |= signal;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue