|
|
|
@ -5,13 +5,13 @@
|
|
|
|
|
//!
|
|
|
|
|
//! A single global instance of [`TaskManager`] called `TASK_MANAGER` controls
|
|
|
|
|
//! all the tasks in the whole operating system.
|
|
|
|
|
//!
|
|
|
|
|
//! A single global instance of [`Processor`] called `PROCESSOR` monitors running
|
|
|
|
|
//! task(s) for each core.
|
|
|
|
|
//!
|
|
|
|
|
//! A single global instance of [`PidAllocator`] called `PID_ALLOCATOR` allocates
|
|
|
|
|
//!
|
|
|
|
|
//! A single global instance of [`Processor`] called `PROCESSOR` monitors running
|
|
|
|
|
//! task(s) for each core.
|
|
|
|
|
//!
|
|
|
|
|
//! A single global instance of [`PidAllocator`] called `PID_ALLOCATOR` allocates
|
|
|
|
|
//! pid for user apps.
|
|
|
|
|
//!
|
|
|
|
|
//!
|
|
|
|
|
//! Be careful when you see `__switch` ASM function in `switch.S`. Control flow around this function
|
|
|
|
|
//! might not be what you expect.
|
|
|
|
|
mod context;
|
|
|
|
@ -27,14 +27,15 @@ use crate::fs::{open_file, OpenFlags};
|
|
|
|
|
use alloc::sync::Arc;
|
|
|
|
|
pub use context::TaskContext;
|
|
|
|
|
use lazy_static::*;
|
|
|
|
|
pub use manager::{fetch_task,TaskManager};
|
|
|
|
|
pub use manager::{fetch_task, TaskManager};
|
|
|
|
|
use switch::__switch;
|
|
|
|
|
use task::{TaskControlBlock, TaskStatus};
|
|
|
|
|
|
|
|
|
|
pub use manager::add_task;
|
|
|
|
|
pub use pid::{pid_alloc, KernelStack, PidHandle,PidAllocator};
|
|
|
|
|
pub use pid::{pid_alloc, KernelStack, PidAllocator, PidHandle};
|
|
|
|
|
pub use processor::{
|
|
|
|
|
current_task, current_trap_cx, current_user_token, run_tasks, schedule, take_current_task,Processor
|
|
|
|
|
current_task, current_trap_cx, current_user_token, run_tasks, schedule, take_current_task,
|
|
|
|
|
Processor,
|
|
|
|
|
};
|
|
|
|
|
/// Suspend the current 'Running' task and run the next task in task list.
|
|
|
|
|
pub fn suspend_current_and_run_next() {
|
|
|
|
@ -89,7 +90,7 @@ pub fn exit_current_and_run_next(exit_code: i32) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
|
///Globle process that init user shell
|
|
|
|
|
///Globle process that init user shell
|
|
|
|
|
pub static ref INITPROC: Arc<TaskControlBlock> = Arc::new({
|
|
|
|
|
let inode = open_file("initproc", OpenFlags::RDONLY).unwrap();
|
|
|
|
|
let v = inode.read_all();
|
|
|
|
|