mirror of
https://github.com/apache/nuttx.git
synced 2026-05-19 03:03:37 +08:00
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:
committed by
Xiang Xiao
parent
2ae62d71a6
commit
165f1cc063
@@ -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[]);
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user