wangchdo commented on code in PR #17308:
URL: https://github.com/apache/nuttx/pull/17308#discussion_r2517598317
##########
sched/wdog/wd_start.c:
##########
@@ -313,6 +313,32 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t
ticks,
reassess |= wd_insert(wdog, ticks, wdentry, arg);
+ /* If the new watchdog expiration time is earlier than the current system
+ * time, trigger a timer interrupt manually. This ensures that the system
+ * processes the watchdog immediately instead of waiting for the next tick.
+ */
+
+ if (clock_compare(wdog->expired, clock_systime_ticks()))
+ {
+# ifdef CONFIG_ARCH_HAVE_IRQTRIGGER
+ if (up_timer_trigger() != OK)
Review Comment:
I think I got your point about using a unified interface.
However, I believe up_alarm_start is more related to setting a new compare
value for the timer.
Setting a new compare value always has potential issues because it involves
several non-atomic steps:
1. Read the current timer value
2. Compare the new value with the current one
3. Set the new compare value based on the comparison
While up_alarm_start is performing these steps, it may be interrupted by an
IRQ. Since the timer count is increasing rapidly, the earlier steps may become
invalid.
This issue probably only matters for very high-resolution timing control, so
maybe the NuttX mainline doesn’t really need this API.
Or maybe we need a new api as: up_alarm_start_immediate()?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]