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


##########
sched/clock/clock_sched_ticks.c:
##########
@@ -62,13 +64,13 @@ static volatile clock_t g_system_ticks = 
INITIAL_SYSTEM_TIMER_TICKS;
 
 void clock_increase_sched_ticks(clock_t ticks)
 {
+  irqstate_t flags;
+
   /* Increment the per-tick scheduler counter */
 
-#ifdef CONFIG_SYSTEM_TIME64
-  atomic64_fetch_add((FAR atomic64_t *)&g_system_ticks, ticks);
-#else
-  atomic_fetch_add((FAR atomic_t *)&g_system_ticks, ticks);
-#endif
+  flags = write_seqlock_irqsave(&g_system_tick_lock);

Review Comment:
   > Overall, write operations will incur an extra irq_save/irq_restore 
operation, while read operations will avoid a 64-bit assignment. Given that 
read operations occur far more frequently, this optimization still delivers 
benefits.
   
   in 32-bit arch,   atomic64  also need irq_save/irq_restore operation,soft 
impl in libs/libc/machine/arch_atomic.c
   



-- 
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]

Reply via email to