Expand description
ArceOS task management module.
This module provides primitives for task management, including task creation, scheduling, sleeping, termination, etc. The scheduler algorithm is configurable by cargo features.
§Cargo Features
multitask
: Enable multi-task support. If it’s enabled, complex task management and scheduling is used, as well as more task-related APIs. Otherwise, only a few APIs with naive implementation is available.irq
: Interrupts are enabled. If this feature is enabled, timer-based APIs can be used, such assleep
,sleep_until
, andWaitQueue::wait_timeout
.preempt
: Enable preemptive scheduling.sched_fifo
: Use the FIFO cooperative scheduler. It also enables themultitask
feature if it is enabled. This feature is enabled by default, and it can be overriden by other scheduler features.sched_rr
: Use the Round-robin preemptive scheduler. It also enables themultitask
andpreempt
features if it is enabled.sched_cfs
: Use the Completely Fair Scheduler. It also enables the themultitask
andpreempt
features if it is enabled.
Macros§
- Define the task extended data.
Structs§
- Current
Task multitask
A wrapper ofAxTaskRef
as the current task. - TaskId
multitask
A unique identifier for a thread. - Task
Inner multitask
The inner task structure. - Wait
Queue multitask
A queue to store sleeping tasks.
Traits§
- Task
ExtMut multitask
A trait to convertTaskInner::task_ext_ptr
to the mutable reference of the concrete type. - Task
ExtRef multitask
A trait to convertTaskInner::task_ext_ptr
to the reference of the concrete type.
Functions§
- current
multitask
Gets the current task. - current_
may_ uninit multitask
Gets the current task, or returnsNone
if the current task is not initialized. - exit
multitask
Exits the current task. - init_
scheduler multitask
Initializes the task scheduler (for the primary CPU). - init_
scheduler_ secondary multitask
Initializes the task scheduler for secondary CPUs. - on_
timer_ tick multitask
andirq
Handles periodic timer ticks for the task manager. - run_
idle multitask
The idle task routine. - set_
current_ affinity multitask
Set the affinity for the current task.AxCpuMask
is used to specify the CPU affinity. Returnstrue
if the affinity is set successfully. - set_
priority multitask
Set the priority for current task. - Current task is going to sleep for the given duration.
- Current task is going to sleep, it will be woken up at the given deadline.
- spawn
multitask
Spawns a new task with the default parameters. - spawn_
raw multitask
Spawns a new task with the given parameters. - spawn_
task multitask
Adds the given task to the run queue, returns the task reference. - Current task gives up the CPU time voluntarily, and switches to another ready task.