xiaoxiang781216 commented on code in PR #14578:
URL: https://github.com/apache/nuttx/pull/14578#discussion_r1825398068


##########
include/nuttx/spinlock.h:
##########
@@ -529,6 +529,7 @@ irqstate_t spin_lock_irqsave_wo_note(FAR volatile 
spinlock_t *lock)
 {
   irqstate_t ret;
   ret = up_irq_save();
+  sched_lock_wo_note();

Review Comment:
   spinlock_irqsave is used only when you need sync with interrupt handle, 
spinlock_lock is enough for normal thread protection. So, the sequence must be 
disabling interrupt and then try hold the lock, to avoid disabling the 
interrupt too long, the compromised approach is:
   ```
   for (; ; )
     {
       ret = up_irq_save();
       if (up_testset() == 0)
         {
            break;
         }
       up_irq_restore(ret);
     }
   ```
   



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