On Sun, Apr 23, 2023 at 10:42 PM Gregory Nutt <spudan...@gmail.com> wrote:
> > > Let's focus on the first two item: > > > > 1. Add sched_lock()'s ability to the enter_critical_section() > > Some will need to explain what this means. What is this? If someone wakes up a high priority thread inside the critical section(not process interrupt), the high priority thread will run immediately. The suggestion is disabling the schedule preempt too until the caller waits something proactively or leaves the critical section. > Why is it > needed? There is not sufficient information in this statement to > understand it. > Here is an example which replace sched lock with the critical section to fix a SMP bug: https://github.com/apache/nuttx/pull/3597/files#diff-2319a97549d1e962ba4aa93ef2de6fafe077a454637afb3b5d1d5a6c9ba65ab2R212-R221 But, since the critical section isn't a superset of the schedule lock, it fails to achieve the requirement highlighted in the comment: /* Make sure that pre-emption is disabled to that we signal all of the * members of the group before any of them actually run. (This does * nothing if were were called from an interrupt handler). */ Since many people don't understand this special behaviour, we found several timing(very hard to reproduce) issues related to this behaviour in the mainline before, that's why Jun made this proposal.