Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions include/nuttx/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -2051,8 +2051,8 @@ int up_alarm_tick_cancel(FAR clock_t *ticks);
*
****************************************************************************/

#if defined(CONFIG_HRTIMER) || \
defined(CONFIG_SCHED_TICKLESS) && defined(CONFIG_SCHED_TICKLESS_ALARM)
#if (defined(CONFIG_HRTIMER) && defined(CONFIG_ALARM_ARCH)) || \
(defined(CONFIG_SCHED_TICKLESS) && defined(CONFIG_SCHED_TICKLESS_ALARM))
int up_alarm_start(FAR const struct timespec *ts);
int up_alarm_tick_start(clock_t ticks);
#endif
Expand Down Expand Up @@ -2123,7 +2123,8 @@ int up_timer_tick_cancel(FAR clock_t *ticks);
*
****************************************************************************/

#if defined(CONFIG_SCHED_TICKLESS) && !defined(CONFIG_SCHED_TICKLESS_ALARM)
#if (defined(CONFIG_HRTIMER) && defined(CONFIG_TIMER_ARCH)) || \
(defined(CONFIG_SCHED_TICKLESS) && !defined(CONFIG_SCHED_TICKLESS_ALARM))
int up_timer_start(FAR const struct timespec *ts);
int up_timer_tick_start(clock_t ticks);
#endif
Expand Down
19 changes: 11 additions & 8 deletions sched/hrtimer/hrtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,29 @@ void hrtimer_process(uint64_t now);
* ns - Expiration time in nanoseconds.
*
* Returned Value:
* OK (0) on success, negated errno on failure.
* None.
*
* Assumptions:
* The underlying timer start function returns 0 on success.
****************************************************************************/

static inline_function void hrtimer_reprogram(uint64_t next_expired)
{
#ifdef CONFIG_SCHED_TICKLESS
int ret;
int ret = 0;
struct timespec ts;
# ifdef CONFIG_SCHED_TICKLESS_ALARM

clock_nsec2time(&ts, next_expired);

#ifdef CONFIG_ALARM_ARCH
ret = up_alarm_start(&ts);
# else
#else
struct timespec current;
up_timer_gettime(&current);
clock_nsec2time(&ts, next_expired);
clock_timespec_subtract(&ts, &current, &ts);
ret = up_timer_start(&ts);
# endif
DEBUGASSERT(ret == 0);
#endif

DEBUGASSERT(ret == 0);
}

/****************************************************************************
Expand Down
4 changes: 4 additions & 0 deletions sched/sched/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[]);
Expand Down
10 changes: 10 additions & 0 deletions sched/sched/sched_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
6 changes: 5 additions & 1 deletion sched/wdog/wdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading