hujun260 opened a new pull request, #18012:
URL: https://github.com/apache/nuttx/pull/18012

   ## Summary
   
   Add spinlock synchronization to sched_note_preemption and 
nxsched_critmon_preemption functions. This change ensures thread-safe access to 
global state during preemption notification and critical section monitoring, 
preventing race conditions in SMP and interrupt-driven environments.
   
   ## Changes
   
   **Files modified:**
   - `drivers/note/note_driver.c`
   - `sched/sched/sched_critmonitor.c`
   
   **Key changes:**
   - Added spinlock protection (`g_note_lock`) to sched_note_preemption to 
guard access to the global note driver list and prevent concurrent 
modifications.
   - Introduced a new spinlock (`g_crimonitor_lock`) in sched_critmonitor.c to 
protect global state in nxsched_critmon_preemption.
   - Wrapped all critical sections in both functions with 
spin_lock_irqsave_notrace/spin_unlock_irqrestore_notrace.
   
   **Synchronization pattern:**
   ```c
   irqstate_t flags;
   flags = spin_lock_irqsave_notrace(&lock);
   // critical section
   spin_unlock_irqrestore_notrace(&lock, flags);


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