You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "hujun260 (via GitHub)" <gi...@apache.org> on 2026/01/19 10:53:11 UTC
[PR] sched: add spinlock to sched_note_preemption and nxsched_critmon_pree… [nuttx]
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] sched: add spinlock to sched_note_preemption and nxsched_critmon_pree… [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #18012:
URL: https://github.com/apache/nuttx/pull/18012
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org