Skip to main content

task_stack_usage

Function task_stack_usage 

Source
pub fn task_stack_usage(id: usize) -> Option<(usize, usize)>
Expand description

A registered task’s stack watermark: (used, total) bytes, or None if id isn’t a live, registered task or has no stack pool entry. Factored out of report so callers that need just one task’s number (e.g. a periodic trace-emitting task) don’t have to re-derive the scratch-window dance below.

On Cortex-M, another task’s pool-allocated stack is outside the currently running task’s MPU region-7 window (region 6 denies the rest of the whole pool by design) — reading it needs the same scratch-window primitive preempt::spawn/stack_pool::release_stack already use for the same reason (a no-op on arches without a whole-pool deny region, e.g. RISC-V). Opening the window disables that deny for the entire pool, not just this stack, so it must run under a critical section: a context switch mid-window would leave every other task’s stack briefly unguarded too.