anchao commented on code in PR #15324:
URL: https://github.com/apache/nuttx/pull/15324#discussion_r1897014572


##########
sched/clock/clock_systime_timespec.c:
##########
@@ -62,21 +62,21 @@
 int clock_systime_timespec(FAR struct timespec *ts)
 {
 #ifdef CONFIG_RTC_HIRES
+  irqstate_t flags;
+
+  flags = spin_lock_irqsave(&g_basetime_lock);
   if (g_rtc_enabled)
     {
-      irqstate_t flags;
-
       up_rtc_gettime(ts);

Review Comment:
   g_basetime_lock is just use for protect g_basetime



##########
sched/clock/clock_initialize.c:
##########
@@ -170,7 +173,20 @@ static void clock_inittime(FAR const struct timespec *tp)
       clock_basetime(&g_basetime);
     }
 
+#ifdef CONFIG_RTC_HIRES
+  if (g_rtc_enabled)
+    {
+      up_rtc_gettime(&ts);

Review Comment:
   race condition may in lower half



##########
sched/clock/clock_settime.c:
##########
@@ -71,16 +72,30 @@ void nxclock_settime(clockid_t clock_id, FAR const struct 
timespec *tp)
    * possible.
    */
 
-  flags = enter_critical_section();
+  flags = spin_lock_irqsave(&g_basetime_lock);
 
   /* Get the elapsed time since power up (in milliseconds).  This is a
    * bias value that we need to use to correct the base time.
    */
 
+#ifdef CONFIG_RTC_HIRES
+  if (g_rtc_enabled)
+    {
+      up_rtc_gettime(&bias);

Review Comment:
   ditto



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to