hujun260 commented on code in PR #15129:
URL: https://github.com/apache/nuttx/pull/15129#discussion_r1879393931


##########
sched/sched/sched_timerexpiration.c:
##########
@@ -494,19 +496,19 @@ void nxsched_timer_expiration(void)
 
   /* Get the interval associated with last expiration */
 
-  flags = enter_critical_section();
+  flags = spin_lock_irqsave_wo_note(&g_lock);
   up_timer_gettick(&ticks);
   g_timer_tick = ticks;
   elapsed = g_timer_interval;
-  leave_critical_section(flags);
+  spin_unlock_irqrestore_wo_note(&g_lock, flags);
 
   /* Process the timer ticks and set up the next interval (or not) */
 
   nexttime = nxsched_timer_process(ticks, elapsed, false);
 
-  flags = enter_critical_section();
+  flags = spin_lock_irqsave_wo_note(&g_lock);
   g_timer_interval = nxsched_timer_start(ticks, nexttime);

Review Comment:
   nxsched_timer_start will call up_timer_start or up_alarm_start 
   I believe that these two functions should be responsible for adding their 
own critical sections. In fact, this is probably how it's done in most cases.
   
![image](https://github.com/user-attachments/assets/41015082-8fff-4c4b-87be-47228b62d948)
   
![image](https://github.com/user-attachments/assets/66de2bd2-24ae-4b93-a74f-46d0fa62d0e1)
   
   However, there may be some overlooked scenarios. Currently, we can add an 
additional critical section in this function. Once all the timer driver codes 
have been replaced with small locks in the future, this critical section can 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: commits-unsubscr...@nuttx.apache.org

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

Reply via email to