On 4/20/2023 7:01 PM, jun hu wrote:
Thank you for your reply and providing additional information.
Based on your suggestion, I believe a reasonable solution about
sched_lock should be step by step.
1 Add sched_lock()'s ability to the enter_critical_section()
I am not sure what this mean. But if you mean calling
enter_critical_secion() in sched_lock(), then it is a very bad idea You
should not do that. enter_critical_section() disables interrupts on all
CPUs and this must never happen when disabling preemption.
In the SMP case, that involves and coordiation with all other CPUs with
inter-CPU messages in order to assure that interrupts are disabled on
all CPUs. That is terrible thing and must not happen.
2 Correct the incorrect usage of sched_lock, since many places
This is already and issue with a lot of discussion:
https://github.com/apache/nuttx/issues/1137
sched_lock and enter_critical_section are used simultaneously
This is done sometimes intentionally in order to minimize the amount of
time that interrupts are disabled. Please do not break that.
3 Remove the sched_lock call from userspace
Finally, change the sched_lock's name.
That is a lot of code to change. I would suggest that you do it is
small logical pieces. (1) must NOT be done. But (2) and (3) are
separate and unrelated and should be separate PRs since they will effect
mant dozens of files and will be difficult to review properly.
If you do (1) it should also be separate because it will be rejected.