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 thepreemptfeature.sched-cfs: Use the Completely Fair Scheduler. It also enables thepreemptfeature.host-test: Use host-safe fallbacks for unit tests.
Modules§
- future
- Future support.
- sync
- Native ArceOS synchronization primitives. Native ArceOS synchronization implementation.
Structs§
- Current
Task - A wrapper of
AxTaskRefas the current task. - Hard
Kernel Timer Callback - Explicit capability for a bounded callback that may execute in hard IRQ.
- Interrupt
Snapshot - A task interruption observation captured before an owner-side safe-point scan.
- IrqNotify
- IRQ-safe deferred notification primitive.
- Kernel
Timer Handle - Stable identity of one host kernel-timer registration.
- Monotonic
Deadline - Finite absolute deadline in the host monotonic clock domain.
- Monotonic
Instant - Sample from the same monotonic clock domain as
MonotonicDeadline. - TaskId
- A unique identifier for a thread.
- Task
Inner - The inner task structure.
- Timer
CpuId - Dense logical CPU identity owning one kernel timer registration.
- Wait
Queue - A queue to store sleeping tasks.
Enums§
- Hard
Kernel Timer Action - Result returned by an explicitly hard-expiry callback.
- Kernel
Timer Action - Result returned by a restartable kernel-timer callback.
- Kernel
Timer Cancel Outcome - Outcome of a non-blocking kernel-timer cancellation attempt.
- Kernel
Timer Error - Errors from the shared host kernel-timer service.
- Task
State - The possible states of a task.
Traits§
- Clock
Event Control - 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
cpuhas spent running a non-idle task since boot. - current
- Gets the current task.
- current_
may_ uninit - Gets the current task, or returns
Noneif 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.
AxCpuMaskis used to specify the CPU affinity. Returnstrueif 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§
- AxCpu
Mask - The wrapper type for
ax_cpumask::CpuMaskwith SMP configuration. - AxTask
Ref - The reference type of a task.
- Kernel
Timer Callback - Callback executed by the owner CPU’s
ktimers/%uservice thread. - Restartable
Kernel Timer Callback - Callback for a stable timer registration that may restart itself.
- Weak
AxTask Ref - The weak reference type of a task.