Crate axtask

Source
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 as sleep, sleep_until, and WaitQueue::wait_timeout.
  • preempt: Enable preemptive scheduling.
  • sched_fifo: Use the FIFO cooperative scheduler. It also enables the multitask 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 the multitask and preempt features if it is enabled.
  • sched_cfs: Use the Completely Fair Scheduler. It also enables the the multitask and preempt features if it is enabled.

Macros§

def_task_ext
Define the task extended data.

Structs§

CurrentTaskmultitask
A wrapper of AxTaskRef as the current task.
TaskIdmultitask
A unique identifier for a thread.
TaskInnermultitask
The inner task structure.
WaitQueuemultitask
A queue to store sleeping tasks.

Traits§

TaskExtMutmultitask
A trait to convert TaskInner::task_ext_ptr to the mutable reference of the concrete type.
TaskExtRefmultitask
A trait to convert TaskInner::task_ext_ptr to the reference of the concrete type.

Functions§

currentmultitask
Gets the current task.
current_may_uninitmultitask
Gets the current task, or returns None if the current task is not initialized.
exitmultitask
Exits the current task.
init_schedulermultitask
Initializes the task scheduler (for the primary CPU).
init_scheduler_secondarymultitask
Initializes the task scheduler for secondary CPUs.
on_timer_tickmultitask and irq
Handles periodic timer ticks for the task manager.
run_idlemultitask
The idle task routine.
set_current_affinitymultitask
Set the affinity for the current task. AxCpuMask is used to specify the CPU affinity. Returns true if the affinity is set successfully.
set_prioritymultitask
Set the priority for current task.
sleep
Current task is going to sleep for the given duration.
sleep_until
Current task is going to sleep, it will be woken up at the given deadline.
spawnmultitask
Spawns a new task with the default parameters.
spawn_rawmultitask
Spawns a new task with the given parameters.
spawn_taskmultitask
Adds the given task to the run queue, returns the task reference.
yield_now
Current task gives up the CPU time voluntarily, and switches to another ready task.

Type Aliases§

AxCpuMaskmultitask
The wrapper type for [cpumask::CpuMask] with SMP configuration.
AxTaskRefmultitask
The reference type of a task.