Skip to main content

Crate ax_task

Crate ax_task 

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

Multi-task scheduling and interrupt handling are mandatory runtime capabilities. Timer-based APIs such as sleep, sleep_until, and WaitQueue::wait_timeout are always available.

  • preempt: Enable preemptive scheduling.
  • FIFO cooperative scheduler is the default when no scheduler feature is selected.
  • sched-rr: Use the Round-robin preemptive scheduler. It also enables the preempt feature.
  • sched-cfs: Use the Completely Fair Scheduler. It also enables the preempt feature.
  • host-test: Use host-safe fallbacks for unit tests.

Modules§

future
Future support.
sync
Native ArceOS synchronization primitives. Native ArceOS synchronization implementation.

Structs§

CurrentTask
A wrapper of AxTaskRef as the current task.
HardKernelTimerCallback
Explicit capability for a bounded callback that may execute in hard IRQ.
InterruptSnapshot
A task interruption observation captured before an owner-side safe-point scan.
IrqNotify
IRQ-safe deferred notification primitive.
KernelTimerHandle
Stable identity of one host kernel-timer registration.
MonotonicDeadline
Finite absolute deadline in the host monotonic clock domain.
MonotonicInstant
Sample from the same monotonic clock domain as MonotonicDeadline.
TaskId
A unique identifier for a thread.
TaskInner
The inner task structure.
TimerCpuId
Dense logical CPU identity owning one kernel timer registration.
WaitQueue
A queue to store sleeping tasks.

Enums§

HardKernelTimerAction
Result returned by an explicitly hard-expiry callback.
KernelTimerAction
Result returned by a restartable kernel-timer callback.
KernelTimerCancelOutcome
Outcome of a non-blocking kernel-timer cancellation attempt.
KernelTimerError
Errors from the shared host kernel-timer service.
TaskState
The possible states of a task.

Traits§

ClockEventControl
Publishes an earlier local deadline to the physical clockevent owner.

Functions§

arm_hard_kernel_timer
Rearms an inactive hard timer on its registration CPU.
cancel_kernel_timer
Cancels a kernel-timer registration without waiting for an executing callback.
cpu_busy_ticks
Scheduler ticks CPU cpu has spent running a non-idle task since boot.
current
Gets the current task.
current_may_uninit
Gets the current task, or returns None if the current task is not initialized.
default_task_stack_size
Returns the default stack size used by task creation helpers.
disarm_hard_kernel_timer
Disarms a stable hard timer without destroying its callback payload.
exit
Exits the current task.
in_atomic_context
Returns whether the current context is atomic, meaning sleeping or rescheduling is not allowed.
init_scheduler
Initializes the task scheduler (for the primary CPU).
init_scheduler_secondary
Initializes the task scheduler for secondary CPUs.
init_timer_service
Starts the owner CPU’s shared soft-timer service.
might_sleep
Marks an operation as one that may sleep or reschedule.
on_timer_irq
Handles a hardware timer interrupt.
on_timer_tick
Handles periodic timer ticks for the task manager.
register_hard_restartable_kernel_timer
Registers a stable callback with explicit hard-IRQ expiry semantics.
register_kernel_timer
Registers a one-shot callback on the calling CPU’s shared timer base.
register_restartable_kernel_timer
Registers a task-context callback that can rearm the same timer identity.
register_task
Registers a task for lookup by its scheduler task id.
register_timer_callback
Registers a callback function to be called on each timer tick.
run_idle
The idle task routine.
set_current_affinity
Set the affinity for the current task. AxCpuMask is used to specify the CPU affinity. Returns true if the affinity is set successfully.
set_priority
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. The deadline is measured against the monotonic clock.
spawn
Spawns a new task with the default parameters.
spawn_raw
Spawns a new task with the given parameters.
spawn_task
Adds the given task to the run queue, returns the task reference.
spawn_task_with
Initializes the given task before adding it to the run queue.
spawn_with_name
Spawns a new task with the given name and the default stack size.
task_by_id
Finds a task by its scheduler task id.
wake_task
Wakes a task that may be sleeping, ensuring it can observe a newly- delivered signal.
wake_task_by_id
Wakes a task by its scheduler task id.
yield_now
Current task gives up the CPU time voluntarily, and switches to another ready task.

Type Aliases§

AxCpuMask
The wrapper type for ax_cpumask::CpuMask with SMP configuration.
AxTaskRef
The reference type of a task.
KernelTimerCallback
Callback executed by the owner CPU’s ktimers/%u service thread.
RestartableKernelTimerCallback
Callback for a stable timer registration that may restart itself.
WeakAxTaskRef
The weak reference type of a task.