This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 165f1cc063d80043a4e5e359ab43e3b222f583cb
Author: wangchengdong <[email protected]>
AuthorDate: Tue Jan 27 11:01:28 2026 +0800

    sched/sched: enable OS tickless mode support using hrtimer
    
    Add support for running the OS in tickless mode with hrtimer, allowing
    the scheduler to operate without periodic ticks while maintaining
    high-resolution timer functionality.
    
    Signed-off-by: Chengdong Wang <[email protected]>
---
 sched/sched/sched.h       |  4 ++++
 sched/sched/sched_timer.c | 10 ++++++++++
 sched/wdog/wdog.h         |  6 +++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/sched/sched/sched.h b/sched/sched/sched.h
index f126a3846e4..db20164b90e 100644
--- a/sched/sched/sched.h
+++ b/sched/sched/sched.h
@@ -309,6 +309,10 @@ extern volatile spinlock_t g_cpu_tasklistlock;
 
 void nxsched_process_tick(void);
 
+#if defined(CONFIG_HRTIMER) && defined(CONFIG_SCHED_TICKLESS)
+int nxsched_hrtimer_tick_start(clock_t tick);
+#endif
+
 int nxthread_create(FAR const char *name, uint8_t ttype, int priority,
                     FAR void *stack_addr, int stack_size, main_t entry,
                     FAR char * const argv[], FAR char * const envp[]);
diff --git a/sched/sched/sched_timer.c b/sched/sched/sched_timer.c
index 9bf3c39aa8b..e59b60debd0 100644
--- a/sched/sched/sched_timer.c
+++ b/sched/sched/sched_timer.c
@@ -108,6 +108,16 @@ nxsched_hrtimer_callback(FAR const struct hrtimer_s 
*hrtimer,
  * Public Functions
  ****************************************************************************/
 
+#if defined(CONFIG_HRTIMER) && defined(CONFIG_SCHED_TICKLESS)
+int nxsched_hrtimer_tick_start(clock_t tick)
+{
+  return hrtimer_start(&g_sched_hrtimer,
+                       nxsched_hrtimer_callback,
+                       tick * NSEC_PER_TICK,
+                       HRTIMER_MODE_ABS);
+}
+#endif
+
 /****************************************************************************
  * Name: nxsched_process_timer
  *
diff --git a/sched/wdog/wdog.h b/sched/wdog/wdog.h
index 8c924ad6135..41ed4807fa4 100644
--- a/sched/wdog/wdog.h
+++ b/sched/wdog/wdog.h
@@ -114,12 +114,16 @@ static inline_function clock_t 
wd_adjust_next_tick(clock_t tick)
 static inline_function void wd_timer_start(clock_t tick)
 {
   clock_t next_tick = wd_adjust_next_tick(tick);
-#ifdef CONFIG_SCHED_TICKLESS_ALARM
+
+#ifdef CONFIG_HRTIMER
+  nxsched_hrtimer_tick_start(tick);
+#elif defined(CONFIG_SCHED_TICKLESS_ALARM)
   up_alarm_tick_start(next_tick);
 #else
   up_timer_tick_start(next_tick - clock_systime_ticks());
 #endif
 }
+
 static inline_function void wd_timer_cancel(void)
 {
   struct timespec ts;

Reply via email to