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§
- CurrentTask
multitask
A wrapper ofAxTaskRef
as the current task. - TaskId
multitask
A unique identifier for a thread. - TaskInner
multitask
The inner task structure. - WaitQueue
multitask
A queue to store sleeping tasks.
Traits§
- TaskExtMut
multitask
A trait to convertTaskInner::task_ext_ptr
to the mutable reference of the concrete type. - TaskExtRef
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.