From bf73fbe774c45470f10da853f8f402b2e979e1db Mon Sep 17 00:00:00 2001 From: chao an Date: Sun, 16 Mar 2025 15:51:14 +0800 Subject: [PATCH] sched: simplify call of get current tcb Replace get current tcb method from nxsched_get_tcb(nxsched_gettid()) to this_task(), change two function calls with inline function to improve performance: FAR struct tcb_s *tcb = nxsched_get_tcb(nxsched_gettid()); FAR struct tcb_s *tcb = this_task(); Signed-off-by: chao an --- drivers/syslog/vsyslog.c | 2 +- sched/sched/sched_setscheduler.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index 9cb27c9ba3..fbb5077967 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -86,7 +86,7 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) struct lib_syslograwstream_s stream; int ret = 0; #ifdef CONFIG_SYSLOG_PROCESS_NAME - FAR struct tcb_s *tcb = nxsched_get_tcb(nxsched_gettid()); + FAR struct tcb_s *tcb = nxsched_self(); #endif #ifdef CONFIG_SYSLOG_TIMESTAMP struct timespec ts; diff --git a/sched/sched/sched_setscheduler.c b/sched/sched/sched_setscheduler.c index 8bfb7de77a..bb54a23788 100644 --- a/sched/sched/sched_setscheduler.c +++ b/sched/sched/sched_setscheduler.c @@ -111,12 +111,15 @@ int nxsched_set_scheduler(pid_t pid, int policy, if (pid == 0) { - pid = nxsched_gettid(); + tcb = this_task(); + } + else + { + tcb = nxsched_get_tcb(pid); } /* Verify that the pid corresponds to a real task */ - tcb = nxsched_get_tcb(pid); if (!tcb) { return -ESRCH;