Expand description
Preemptive task stack pool (plan.md §3).
All preemptive task stacks live in one contiguous, power-of-two-aligned
.task_stacks section. Stacks are carved from it at spawn time with
size-aligned addresses (sizes must be powers of two), which is exactly
what the CM3 MPU (per-switch current-stack region) and the RISC-V PMP
(NAPOT guard bands at the low end of each stack) require.
__task_stacks_start/__task_stacks_end are part of the linker
contract every board’s linker script provides (documented in
docs/porting.md) — not an arch/board API call, just fixed symbol
names, the same on every real target. The host test backend has no
linker-provided pool at all (gated on the host-port feature, not
target_arch: the distinction is “is there a real linker script”,
which is unrelated to which arch a real target happens to be); there,
alloc_stack always returns None and callers fall back to their
own static stacks.
Functions§
- alloc_
stack - Allocate a size-aligned stack of
sizebytes from the pool, with a guard band (usually 64 bytes — see [guard_size]) at its low end (plan.md §3.2).sizemust be a power of two (the MPU/PMP region alignment requires it) and at least as large as the guard band. - contains
- Is address
addrinside the task-stack pool? - pool_
bounds - Pool bounds
(base, len)on embedded targets;(0, 0)on the host test backend. - release_
stack - Release a stack back to the pool (plan.md §5.4 despawn/respawn). The
slice is refilled with
0xAAso watermarking keeps working after the stack is reused. No-op if the slice did not come from the pool.