Skip to content

Commit 7b9caba

Browse files
committed
sched/sched: Add nxsched_hrtimer_start to fix hrtimer tickless support issue
When hrtimer is enabled, the tickless scheduler should call nxsched_hrtimer_start to start the timer, this is because the tick system is support by hrtimer Signed-off-by: Chengdong Wang <[email protected]>
1 parent 3c6f349 commit 7b9caba

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

include/nuttx/arch.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,6 +2461,25 @@ void up_ndelay(unsigned long nanoseconds);
24612461
* architecture specific logic.
24622462
****************************************************************************/
24632463

2464+
/****************************************************************************
2465+
* Name: nxsched_hrtimer_start
2466+
*
2467+
* Description:
2468+
* (Re)start the scheduler high-resolution timer with a new expiration
2469+
* based on the specified tick interval.
2470+
*
2471+
* Input Parameters:
2472+
* ticks - Number of scheduler ticks until expiration.
2473+
*
2474+
* Returned Value:
2475+
* Zero on success; a negated errno value on failure.
2476+
*
2477+
****************************************************************************/
2478+
2479+
#ifndef CONFIG_HRTIMER
2480+
int nxsched_hrtimer_start(clock_t ticks);
2481+
#endif
2482+
24642483
/****************************************************************************
24652484
* Name: nxsched_process_timer
24662485
*

sched/hrtimer/hrtimer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static inline_function
120120
int hrtimer_starttimer(uint64_t ns)
121121
{
122122
struct timespec ts;
123-
int ret;
123+
int ret = OK;
124124

125125
/* Convert nanoseconds to timespec */
126126

sched/sched/sched_timerexpiration.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,20 @@ static clock_t nxsched_timer_start(clock_t ticks, clock_t interval)
411411
interval = interval <= (CONFIG_TIMER_ADJUST_USEC / USEC_PER_TICK) ? 0 :
412412
interval - (CONFIG_TIMER_ADJUST_USEC / USEC_PER_TICK);
413413

414-
#ifdef CONFIG_SCHED_TICKLESS_ALARM
414+
#ifdef CONFIG_HRTIMER
415+
nxsched_hrtimer_start(ticks + interval);
416+
#else
417+
# ifdef CONFIG_SCHED_TICKLESS_ALARM
415418
/* Convert the delay to a time in the future (with respect
416419
* to the time when last stopped the timer).
417420
*/
418421

419422
ret = up_alarm_tick_start(ticks + interval);
420-
#else
423+
# else
421424
/* [Re-]start the interval timer */
422425

423426
ret = up_timer_tick_start(interval);
427+
# endif
424428
#endif
425429

426430
if (ret < 0)

0 commit comments

Comments
 (0)