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 <wangchengdong@lixiang.com>
This commit is contained in:
wangchengdong
2026-01-27 11:01:28 +08:00
committed by Xiang Xiao
parent 2ae62d71a6
commit 165f1cc063
3 changed files with 19 additions and 1 deletions
+4
View File
@@ -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[]);
+10
View File
@@ -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
*
+5 -1
View File
@@ -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;