hujun260 commented on issue #14593:
URL: https://github.com/apache/nuttx/issues/14593#issuecomment-2457103481

   > what do you recommend to use instead?
   > mutex? semaphore? spin lock?
   
   Based on the program logic, deciding which synchronization strategy to use,
   I believe that if the protected region executes quickly without context 
switching,
   spinlock is the preferred choice and recursive locks should not be used.
   
   
   
   
   > how do you think about introducing a bit higher-level primitives for the 
kernel? eg. solaris-like adaptive mutex
   
   Using general locks strategy can easily lead to misuse and a decline in code 
quality.
   We need more precise lock behavior, especially in RTOS, where more precise 
time control
   and good programming practices are required.
   
   Just like critical sections in NuttX, which are used everywhere
   and significantly degrade performance in smp complex scenarios.
   
   
   > so, the current semantics of enter_critical_section is:
   > 
   > * it disables interrupts on the calling CPU.
   > * it does NOT disable interrupts on remote CPUs.
   > * it acquires the system-global, recursive lock, which is automatically 
released/re-aquired when the current thread blocks/wakes up. (similarly to the 
big kernel lock in the traditional unix.)
   > 
   > is it right?
   
   yes 
   Additionally, the old enter_critical_section impl was more complex than the 
current one,
   as it also handling sync pause strategies. We have already made some 
simplifications.
   Looking towards the future, we need to remove the recursive strategy and 
auto released/re-aquired strategy within the critical section, turning it into 
a simple spinlock. But this will take a relatively long time,
   


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