On 8/28/2024 7:15 PM, Daniel Appiagyei wrote:
Hi Gregory, thank you for the quick response!

RE: 'lockcount' needing to be in a critical section:
That's good information to know, I wasn't aware before. I'm searching nuttx
for exact matches of the string 'sched_lock();' to find occurrences and
seeing this is not always done.

It should always be done.  Sometimes it is not so easy to determine if you are in a critical section or not by inspecting the code.  The old BSD file headers had an "Assumptions" section where that was documented in comments.  It would state if being in a critical section was an entry requirement or not.  But those file headers were removed when NuttX became Apache.

It would be a good exercise to verify that the critical section is always in place and fix any oversights.

The critical section is needed not just for the memory barrier. lockcount++ is a read modify write operation on most CPUs and must be made atomic.


Reply via email to