Module os::task

source · []
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. Control flow around this function might not be what you expect.

Modules

Implementation of TaskContext

Rust wrapper around __switch.

Types related to task management

Structs

a TaskManager instance through lazy_static!

task context structure containing some registers

task control block structure

The task manager, where all the tasks are managed.

The task manager inner in ‘UPSafeCell’

Enums

task status: UnInit, Ready, Running, Exited

Functions

Switch to the context of next_task_cx_ptr, saving the current context in current_task_cx_ptr.

Get the current ‘Running’ task’s trap contexts.

Get the current ‘Running’ task’s token.

Exit the current ‘Running’ task and run the next task in task list.

Change the status of current Running task into Exited.

Change the status of current Running task into Ready.

Run the first task in task list.

Switch current Running task to the task we have found, or there is no Ready task and we can exit with all applications completed

Suspend the current ‘Running’ task and run the next task in task list.