xiaoxiang781216 commented on code in PR #15929: URL: https://github.com/apache/nuttx/pull/15929#discussion_r1983303339
########## arch/risc-v/src/common/riscv_mtimer.c: ########## @@ -211,19 +210,20 @@ static int riscv_mtimer_max_delay(struct oneshot_lowerhalf_s *lower, static int riscv_mtimer_start(struct oneshot_lowerhalf_s *lower, oneshot_callback_t callback, void *arg, - const struct timespec *ts) + clock_t ticks) { struct riscv_mtimer_lowerhalf_s *priv = (struct riscv_mtimer_lowerhalf_s *)lower; irqstate_t flags; uint64_t mtime; + clock_t current; uint64_t alarm; flags = up_irq_save(); mtime = riscv_mtimer_get_mtime(priv); - alarm = mtime + ts->tv_sec * priv->freq + - ts->tv_nsec * priv->freq / NSEC_PER_SEC; + current = mtime * TICK_PER_SEC / priv->freq; + alarm = (current + ticks) * priv->freq / TICK_PER_SEC; Review Comment: For example, let's assume mtime 1MHz and SCHED_CPULOAD_TICKSPERSEC=1000, the accuracy of clock_gettime change from 1us to 1ms with this patch. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org