Skip to content

Commit

Permalink
sched_lock: we can remove these sched_lock,
Browse files Browse the repository at this point in the history
There is no context switching in the protected area

purpose:
1 sched_lock is very time-consuming, and reducing its invocations can improve performance.
2 sched_lock is prone to misuse, and narrowing its scope of use is to prevent people from referencing incorrect code and using it

test:
We can use qemu for testing.
compiling
make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20
running
qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx

We have also tested this patch on other ARM hardware platforms.

Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Apr 16, 2024
1 parent b0504f1 commit 1f68f1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 3 additions & 2 deletions drivers/syslog/syslog_intbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,15 @@ int syslog_add_intbuffer(int ch)
int syslog_flush_intbuffer(bool force)
{
syslog_putc_t putfunc;
irqstate_t flags;
int ch;
int i;

/* This logic is performed with the scheduler disabled to protect from
* concurrent modification by other tasks.
*/

sched_lock();
flags = enter_critical_section();

do
{
Expand Down Expand Up @@ -293,7 +294,7 @@ int syslog_flush_intbuffer(bool force)
}
while (ch != EOF);

sched_unlock();
leave_critical_section(flags);

return ch;
}
Expand Down
4 changes: 0 additions & 4 deletions sched/misc/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,6 @@ void _assert(FAR const char *filename, int linenum,

flags = enter_critical_section();

sched_lock();

/* try to save current context if regs is null */

if (regs == NULL)
Expand Down Expand Up @@ -672,7 +670,5 @@ void _assert(FAR const char *filename, int linenum,
#endif
}

sched_unlock();

leave_critical_section(flags);
}

0 comments on commit 1f68f1e

Please sign in to comment.