xiaoxiang781216 commented on code in PR #18131:
URL: https://github.com/apache/nuttx/pull/18131#discussion_r2726262318
##########
sched/hrtimer/hrtimer.h:
##########
@@ -33,8 +33,18 @@
#include <nuttx/hrtimer.h>
#include <nuttx/seqlock.h>
+#include "sched/sched.h"
+
#ifdef CONFIG_HRTIMER
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Delay used while waiting for a running hrtimer callback to complete */
+
+#define HRTIMER_CANCEL_SYNC_DELAY_MS 5
Review Comment:
let's create a new patch changing timeout to:
```
#define HRTIMER_CANCEL_SYNC_DELAY_US CONFIG_USEC_PER_TICK
```
##########
sched/hrtimer/hrtimer.h:
##########
@@ -310,5 +310,115 @@ static inline_function bool hrtimer_is_first(FAR
hrtimer_t *hrtimer)
#endif
}
+/****************************************************************************
+ * Name: hrtimer_mark_running
+ *
+ * Description:
+ * Mark the timer as running.
+ *
+ * Input Parameters:
+ * timer - The timer to be marked.
+ * cpu - The CPU core Id.
+ *
+ * Returned Value:
+ * None.
+ *
+ * Assumption:
+ * The caller must hold the lock.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SMP
+# define hrtimer_mark_running(timer, cpu) \
+ (g_hrtimer_running[cpu] = (uintptr_t)(timer))
+#else
+# define hrtimer_mark_running(timer, cpu) UNUSED(cpu)
+#endif
+#define hrtimer_unmark_running(cpu) hrtimer_mark_running(NULL, cpu)
+
+/****************************************************************************
+ * Name: hrtimer_is_running
+ *
+ * Description:
+ * Check if the CPU core is running the timer.
+ *
+ * Input Parameters:
+ * timer - The timer to be marked.
+ * cpu - The CPU core Id.
+ *
+ * Returned Value:
+ * true if the CPU core is running the timer, false otherwise.
+ *
+ * Assumption:
+ * The caller must hold the lock.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SMP
+# define hrtimer_is_running(timer, cpu) \
+ (g_hrtimer_running[cpu] == (uintptr_t)(timer))
+#else
+# define hrtimer_is_running(timer, cpu) (true)
+#endif
+#define hrtimer_is_cancelled(timer, cpu) \
Review Comment:
hrtimer_is_cancelling
##########
sched/hrtimer/hrtimer_cancel.c:
##########
@@ -60,11 +60,12 @@
#ifdef CONFIG_SMP
static inline_function bool hrtimer_is_active(FAR hrtimer_t *hrtimer)
{
- bool is_active = false;
+ int cpu;
+ bool is_active = false;
Review Comment:
remove the extra spaces
##########
sched/hrtimer/hrtimer.h:
##########
@@ -310,5 +310,115 @@ static inline_function bool hrtimer_is_first(FAR
hrtimer_t *hrtimer)
#endif
}
+/****************************************************************************
+ * Name: hrtimer_mark_running
+ *
+ * Description:
+ * Mark the timer as running.
+ *
+ * Input Parameters:
+ * timer - The timer to be marked.
+ * cpu - The CPU core Id.
+ *
+ * Returned Value:
+ * None.
+ *
+ * Assumption:
+ * The caller must hold the lock.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SMP
+# define hrtimer_mark_running(timer, cpu) \
+ (g_hrtimer_running[cpu] = (uintptr_t)(timer))
+#else
+# define hrtimer_mark_running(timer, cpu) UNUSED(cpu)
Review Comment:
remove the extra space
--
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]