Expand description
Fixed-size timer queue backing crate::time::Sleep.
A task calling Sleep::<MICROS>::new().await registers a deadline here
instead of busy-polling — the arch timer ISR (riscv::timer_tick /
cortex_m::systick_handler) calls poll_timers on every tick, which
wakes any task whose deadline has passed. This is what makes
port::arch::idle() (WFI) a real power-saving wait instead of a spin loop:
between ticks, no task is marked ready, so the executor actually sleeps.
Slots are u64-deadline UnsafeCells guarded by crate::critical
rather than atomics, since RV32 has no native 64-bit atomic ops (even
with the A extension, which is 32-bit/pointer-width only).
Structs§
- Timer
Handle - Handle to a registered timer slot; carries the slot index and the
registered deadline so a stale [
cancel_deadline] (after the slot was already freed and reused) is a harmless no-op (plan.md [B7]). - Timer
Queue Full - Queue-full error returned by timer registration APIs (plan.md §4.3).
Constants§
- MAX_
TIMERS - Maximum number of outstanding timers (RIVET_MAX_TIMERS; one per task
blocked in
Sleep, so this should be >=MAX_TASKSif every task might sleep concurrently).
Functions§
- poll_
timers - Scan for expired timers and wake their tasks. Call from the platform timer ISR on every tick.
- slots_
in_ use - Count of timer slots currently in use. Used by host-test reset/
inspection helpers and by [
crate::report].