Expand description
Task management implementation
Everything about task management, like starting and switching tasks is implemented here.
A single global instance of TaskManager called TASK_MANAGER controls
all the tasks in the operating system.
Be careful when you see __switch ASM function in switch.S. Control flow around this function
might not be what you expect.
Modules§
- context 🔒
- Implementation of
TaskContext - switch 🔒
- Rust wrapper around
__switch. - task 🔒
- Types related to task management
Structs§
- TASK_
MANAGER - a
TaskManagerglobal instance through lazy_static! - Task
Context - task context structure containing some registers
- Task
Manager - The task manager, where all the tasks are managed.
- Task
Manager 🔒Inner - The task manager inner in ‘UPSafeCell’
Functions§
- change_
program_ brk - Change the current ‘Running’ task’s program break
- current_
trap_ cx - Get the current ‘Running’ task’s trap contexts.
- current_
user_ token - Get the current ‘Running’ task’s token.
- exit_
current_ and_ run_ next - Exit the current ‘Running’ task and run the next task in task list.
- mark_
current_ 🔒exited - Change the status of current
Runningtask intoExited. - mark_
current_ 🔒suspended - Change the status of current
Runningtask intoReady. - run_
first_ task - Run the first task in task list.
- run_
next_ 🔒task - Switch current
Runningtask to the task we have found, or there is noReadytask and we can exit with all applications completed - suspend_
current_ and_ run_ next - Suspend the current ‘Running’ task and run the next task in task list.