You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2025/11/19 04:25:09 UTC
(nuttx) 07/11: timers/arch_alarm: Fix oneshot callback for non-tickless.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 556b89bcdb0827acfa5d9564ec44b3bad2d40520
Author: ouyangxiangzhen <ou...@xiaomi.com>
AuthorDate: Tue Jul 29 19:34:02 2025 +0800
timers/arch_alarm: Fix oneshot callback for non-tickless.
This commit fixed oneshot callback for non-tickless using tick-aligned
absolute oneshot interfaces.
Signed-off-by: ouyangxiangzhen <ou...@xiaomi.com>
---
drivers/timers/arch_alarm.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/timers/arch_alarm.c b/drivers/timers/arch_alarm.c
index 2d1a32a1da1..7a825b06446 100644
--- a/drivers/timers/arch_alarm.c
+++ b/drivers/timers/arch_alarm.c
@@ -47,20 +47,12 @@ static clock_t g_current_tick;
static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
FAR void *arg)
{
- clock_t now = 0;
+ clock_t now;
ONESHOT_TICK_CURRENT(g_oneshot_lower, &now);
#ifdef CONFIG_SCHED_TICKLESS
nxsched_tick_expiration(now);
#else
- /* Start the next tick first, in order to minimize latency. Ideally
- * the ONESHOT_TICK_START would also return the current tick so that
- * the retrieving the current tick and starting the new one could be done
- * atomically w. respect to a HW timer
- */
-
- ONESHOT_TICK_START(g_oneshot_lower, 1);
-
/* It is always an error if this progresses more than 1 tick at a time.
* That would break any timer based on wdog; such timers might timeout
* early. Add a DEBUGASSERT here to catch those errors. It is not added
@@ -68,13 +60,13 @@ static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
* would occur due to HW timers possibly running while CPU is being halted.
*/
- /* DEBUGASSERT(now - g_current_tick <= 1); */
-
- while (now - g_current_tick > 0)
+ while (!clock_compare(now, g_current_tick))
{
g_current_tick++;
nxsched_process_timer();
}
+
+ ONESHOT_TICK_ABSOLUTE(g_oneshot_lower, now + 1);
#endif
}