xiaoxiang781216 commented on code in PR #18224:
URL: https://github.com/apache/nuttx/pull/18224#discussion_r2736727659
##########
sched/hrtimer/hrtimer.h:
##########
@@ -103,6 +104,22 @@ extern uintptr_t g_hrtimer_running[CONFIG_SMP_NCPUS];
* Public Function Prototypes
****************************************************************************/
+/****************************************************************************
+ * Name: hrtimer_initialize
+ *
+ * Description:
+ * Initialize the high-resolution timer for timing subsystem.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None.
+ *
+ ****************************************************************************/
+
+void hrtimer_initialize(void);
Review Comment:
remove
##########
sched/hrtimer/hrtimer.h:
##########
@@ -84,6 +84,7 @@ extern seqcount_t g_hrtimer_lock;
/* Red-Black tree containing all active high-resolution timers */
extern struct hrtimer_tree_s g_hrtimer_tree;
+extern struct FAR hrtimer_s *g_cached_first;
Review Comment:
g_hrtimer_head
##########
sched/hrtimer/hrtimer.h:
##########
@@ -188,37 +194,22 @@ int hrtimer_compare(FAR const hrtimer_node_t *a,
RB_PROTOTYPE(hrtimer_tree_s, hrtimer_node_s, entry, hrtimer_compare);
#endif
-/****************************************************************************
- * Name: hrtimer_is_armed
- *
- * Description:
- * Test whether a timer is currently armed (inserted into the container).
- *
- * Returned Value:
- * true if armed, false otherwise.
- ****************************************************************************/
-
-static inline_function bool hrtimer_is_armed(FAR hrtimer_t *hrtimer)
-{
- return hrtimer->func != NULL;
-}
-
/****************************************************************************
* Name: hrtimer_remove
*
* Description:
- * Remove a timer from the container and mark it as unarmed.
+ * Remove a timer from the queue and mark it as dequeued.
****************************************************************************/
-static inline_function void hrtimer_remove(FAR hrtimer_t *hrtimer)
+static inline_function void hrtimer_remove(FAR hrtimer_t *hrtimer)queue
Review Comment:
remove queue
##########
sched/wdog/wd_initialize.c:
##########
@@ -41,6 +41,10 @@
struct list_node g_wdactivelist = LIST_INITIAL_VALUE(g_wdactivelist);
+#ifdef CONFIG_HRTIMER
+struct hrtimer_s g_wdog_hrtimer;
+#endif
+
#ifdef CONFIG_SCHED_TICKLESS
bool g_wdtimernested;
Review Comment:
do we still need g_wdtimernested
##########
sched/sched/sched_processtickless.c:
##########
@@ -362,8 +363,9 @@ static void nxsched_timer_start(clock_t ticks, clock_t
interval)
*
****************************************************************************/
-void nxsched_process_tick(void)
+void nxsched_process_timer(void)
{
+#ifndef CONFIG_HRTIMER
Review Comment:
`#ifdef CONFIG_HRTIMER`
##########
sched/wdog/wdog.h:
##########
@@ -110,13 +155,20 @@ static inline_function clock_t
wd_adjust_next_tick(clock_t tick)
return next_tick;
}
+# else
+# define wd_adjust_next_tick(tick) (tick)
+# endif
-static inline_function void wd_timer_start(clock_t tick)
+static inline_function void wd_timer_start(clock_t tick, bool in_expiration)
{
clock_t next_tick = wd_adjust_next_tick(tick);
-
#ifdef CONFIG_HRTIMER
- nxsched_hrtimer_tick_start(tick);
+ DEBUGASSERT(next_tick <= CLOCK_MAX / NSEC_PER_SEC);
+ if (!in_expiration)
+ {
+ hrtimer_start(&g_wdog_hrtimer, wd_timer,
+ TICK2NSEC((uint64_t)next_tick), HRTIMER_MODE_ABS);
Review Comment:
why need cast
##########
sched/wdog/wd_initialize.c:
##########
@@ -41,6 +41,10 @@
struct list_node g_wdactivelist = LIST_INITIAL_VALUE(g_wdactivelist);
+#ifdef CONFIG_HRTIMER
+struct hrtimer_s g_wdog_hrtimer;
Review Comment:
g_wdtimer
##########
sched/hrtimer/hrtimer_cancel.c:
##########
@@ -94,8 +93,7 @@ int hrtimer_cancel(FAR hrtimer_t *hrtimer)
if (hrtimer_remove(hrtimer))
{
- first = hrtimer_get_first();
- hrtimer_reprogram(first->expired);
+ hrtimer_reprogram(hrtimer_get_first()->expired);
Review Comment:
let's keep the origin code
##########
sched/wdog/wdog.h:
##########
@@ -110,13 +155,20 @@ static inline_function clock_t
wd_adjust_next_tick(clock_t tick)
return next_tick;
}
+# else
+# define wd_adjust_next_tick(tick) (tick)
+# endif
-static inline_function void wd_timer_start(clock_t tick)
+static inline_function void wd_timer_start(clock_t tick, bool in_expiration)
Review Comment:
nested?
--
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]