hal::clock
A free-running monotonic microsecond clock.
Distinct from [crate::tick::TickSource]: the tick is the periodic
scheduling interrupt, counted in milliseconds; this is a free-running
counter read for absolute time and for measuring intervals shorter than a
tick. Not every SoC has a spare hardware counter to spend on one, so both
methods default to “there isn’t one” — a SoC without a monotonic counter is
answered from the scheduler tick instead, a thousand times coarser but still
monotonic and correctly ordered.
Traits
Section titled “Traits”MonotonicClock
Section titled “MonotonicClock”trait MonotonicClock { unsafe fn init() -> bool fn now_us() -> Option<u64>}A monotonic microsecond clock, for the SoCs that have a spare counter.
The kernel selects one implementation and reads it through this trait, so a caller that wants absolute time names no chip. A SoC with no such counter implements nothing and takes the defaults; the kernel then falls back to the tick.