Struct os::task::TaskManager
source · [−]pub struct TaskManager {
num_app: usize,
inner: UPSafeCell<TaskManagerInner>,
}
Expand description
The task manager, where all the tasks are managed.
Functions implemented on TaskManager
deals with all task state transitions
and task context switching. For convenience, you can find wrappers around it
in the module level.
Most of TaskManager
are hidden behind the field inner
, to defer
borrowing checks to runtime. You can see examples on how to use inner
in
existing functions on TaskManager
.
Fields
num_app: usize
total number of tasks
inner: UPSafeCell<TaskManagerInner>
use inner value to get mutable access
Implementations
sourceimpl TaskManager
impl TaskManager
sourcefn run_first_task(&self) -> !
fn run_first_task(&self) -> !
Run the first task in task list.
Generally, the first task in task list is an idle task (we call it zero process later). But in ch3, we load apps statically, so the first task is a real app.
sourcefn mark_current_suspended(&self)
fn mark_current_suspended(&self)
Change the status of current Running
task into Ready
.
sourcefn mark_current_exited(&self)
fn mark_current_exited(&self)
Change the status of current Running
task into Exited
.
sourcefn find_next_task(&self) -> Option<usize>
fn find_next_task(&self) -> Option<usize>
Find next task to run and return task id.
In this case, we only return the first Ready
task in task list.
sourcefn run_next_task(&self)
fn run_next_task(&self)
Switch current Running
task to the task we have found,
or there is no Ready
task and we can exit with all applications completed
Auto Trait Implementations
impl !RefUnwindSafe for TaskManager
impl Send for TaskManager
impl Sync for TaskManager
impl Unpin for TaskManager
impl UnwindSafe for TaskManager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more