This is an automated email from the ASF dual-hosted git repository. archer pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit d7ce29774c319b11123c12b0dd4c79f838b6bce1 Author: wangchengdong <[email protected]> AuthorDate: Tue Dec 16 19:53:20 2025 +0800 sched/hrtimer: Add motivation to hrtimer module description Enhance the hrtimer module description by explaining its purpose and use cases, making it more readable and understandable for humans. Signed-off-by: Chengdong Wang <[email protected]> --- Documentation/reference/os/time_clock.rst | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Documentation/reference/os/time_clock.rst b/Documentation/reference/os/time_clock.rst index 6f6e112ae1d..e2f7f4a9ace 100644 --- a/Documentation/reference/os/time_clock.rst +++ b/Documentation/reference/os/time_clock.rst @@ -661,14 +661,20 @@ or ``kill()`` to communicate with NuttX tasks. High-resolution Timer Interfaces ================================ -NuttX provides a high-resolution timer facility. This facility -allows the NuttX user to specify a hrtimer function that -will run after a specified delay in nanosec resolution. The hrtimer -function will run in the context of the timer interrupt handler. -Because of this, a limited number of NuttX interfaces are available to he -hrtimer function. However, the hrtimer function may -use ``mq_send()``, ``sigqueue()``, ``nxevent_post()``, or ``kill()`` -to communicate with NuttX tasks. +Hard real-time applications, such as motor control, often +require nanosecond-level task timing, which tick-based timers +like wdog cannot provide. Reducing the tick interval to micro- +or nanoseconds is impractical, as it would overload the CPU with interrupts. + +To address this, NuttX provides a high-resolution timer (hrtimer), +which delivers true nanosecond-level precision. Unlike wdog’s list-based timers, +hrtimer uses a red-black tree for efficient management of large numbers of timers, +an important advantage in hard real-time systems like vehicle control. + +A user can register an hrtimer callback to execute after a specified delay. +The callback runs in the timer interrupt context, so only limited NuttX interfaces +are available, such as ``mq_send()``, ``sigqueue()``, ``nxevent_post()``, or ``kill()``, +to communicate with tasks. - :c:func:`hrtimer_init` - :c:func:`hrtimer_cancel`
