anchao commented on code in PR #17573:
URL: https://github.com/apache/nuttx/pull/17573#discussion_r2684386661
##########
sched/sched/sched_processtimer.c:
##########
@@ -44,11 +44,116 @@
#include "sched/sched.h"
#include "wdog/wdog.h"
#include "clock/clock.h"
+#include "hrtimer/hrtimer.h"
+
+#ifdef CONFIG_HRTIMER
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static uint64_t
+nxsched_hrtimer_callback(FAR const hrtimer_t *hrtimer,
+ uint64_t expired);
+
+static void nxsched_process_tick(void);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* Scheduler-owned high-resolution timer instance.
+ *
+ * This timer acts as the time source for scheduler-related events:
+ *
+ * - Periodic scheduler ticks in non-tickless mode
+ * - Dynamic expiration points in tickless mode
+ *
+ * The timer is initialized lazily to avoid unnecessary setup when
+ * CONFIG_HRTIMER is enabled but not used immediately.
+ */
+
+static hrtimer_t g_nxsched_hrtimer =
+{
+ .func = nxsched_hrtimer_callback,
+};
/****************************************************************************
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: nxsched_hrtimer_callback
+ *
+ * Description:
+ * Callback invoked by the high-resolution timer framework when the
+ * scheduler timer expires.
+ *
+ * Behavior depends on scheduler configuration:
+ *
+ * CONFIG_SCHED_TICKLESS:
+ * - Query current high-resolution time
+ * - Convert time to scheduler ticks
+ * - Notify scheduler via nxsched_tick_expiration()
+ *
+ * !CONFIG_SCHED_TICKLESS:
+ * - Re-arm the next periodic tick
+ * - Process a single scheduler tick
+ *
+ * Input Parameters:
+ * hrtimer - Pointer to the expired high-resolution timer
+ *
+ * Returned Value:
+ * In non-tickless mode, returns the interval until the next expiration.
+ * In tickless mode, the return value is ignored.
+ *
+ ****************************************************************************/
+
+static uint64_t
+nxsched_hrtimer_callback(FAR hrtimer_t *hrtimer, uint64_t expired)
+{
+ UNUSED(hrtimer);
+ UNUSED(expired);
+
+#ifdef CONFIG_SCHED_TICKLESS
+ nxsched_tick_expiration();
+#else
+ nxsched_process_tick();
+ return NSEC_PER_TICK;
+#endif
Review Comment:
```suggestion
#endif
return NSEC_PER_TICK;
```
or return value could be removed?
--
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]