This is an automated email from the ASF dual-hosted git repository. archer pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9d8f0ace4055914770e348bde92495319991f646 Author: wangchengdong <[email protected]> AuthorDate: Mon Jan 19 13:07:42 2026 +0800 sched/sched: consolidate nxsched_process_timer into sched_timer.c Consolidate nxsched_process_timer into sched_timer.c, and introduce nxsched_process_tick() to improve readability and maintainability of the scheduler timer processing logic. Signed-off-by: Chengdong Wang <[email protected]> --- sched/sched/CMakeLists.txt | 7 +-- sched/sched/Make.defs | 6 +-- sched/sched/sched.h | 2 + .../{sched_processtimer.c => sched_processtick.c} | 6 +-- ...ed_timerexpiration.c => sched_tickexpiration.c} | 4 +- sched/sched/sched_timer.c | 51 ++++++++++++++++++++++ 6 files changed, 65 insertions(+), 11 deletions(-) diff --git a/sched/sched/CMakeLists.txt b/sched/sched/CMakeLists.txt index 782234f846d..14c731bdcca 100644 --- a/sched/sched/CMakeLists.txt +++ b/sched/sched/CMakeLists.txt @@ -48,7 +48,8 @@ set(SRCS sched_sysinfo.c sched_get_stateinfo.c sched_switchcontext.c - sched_sleep.c) + sched_sleep.c + sched_timer.c) if(DEFINED CONFIG_STACKCHECK_MARGIN) if(NOT CONFIG_STACKCHECK_MARGIN EQUAL -1) @@ -97,9 +98,9 @@ if(NOT CONFIG_SCHED_CPULOAD_NONE) endif() if(CONFIG_SCHED_TICKLESS) - list(APPEND SRCS sched_timerexpiration.c) + list(APPEND SRCS sched_tickexpiration.c) else() - list(APPEND SRCS sched_processtimer.c) + list(APPEND SRCS sched_processtick.c) endif() if(CONFIG_SCHED_CRITMONITOR) diff --git a/sched/sched/Make.defs b/sched/sched/Make.defs index 71a7bc2ce6b..3bb641e84df 100644 --- a/sched/sched/Make.defs +++ b/sched/sched/Make.defs @@ -30,7 +30,7 @@ CSRCS += sched_yield.c sched_rrgetinterval.c sched_foreach.c CSRCS += sched_lock.c sched_unlock.c sched_lockcount.c CSRCS += sched_idletask.c sched_self.c sched_get_stackinfo.c sched_get_tls.c CSRCS += sched_sysinfo.c sched_get_stateinfo.c sched_getcpu.c -CSRCS += sched_switchcontext.c sched_sleep.c +CSRCS += sched_switchcontext.c sched_sleep.c sched_timer.c ifneq ($(CONFIG_STACKCHECK_MARGIN),) ifneq ($(CONFIG_STACKCHECK_MARGIN),-1) @@ -79,9 +79,9 @@ endif endif ifeq ($(CONFIG_SCHED_TICKLESS),y) -CSRCS += sched_timerexpiration.c +CSRCS += sched_tickexpiration.c else -CSRCS += sched_processtimer.c +CSRCS += sched_processtick.c endif ifeq ($(CONFIG_SCHED_CRITMONITOR),y) diff --git a/sched/sched/sched.h b/sched/sched/sched.h index 3fb922585cb..f126a3846e4 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -307,6 +307,8 @@ extern volatile spinlock_t g_cpu_tasklistlock; * Public Function Prototypes ****************************************************************************/ +void nxsched_process_tick(void); + int nxthread_create(FAR const char *name, uint8_t ttype, int priority, FAR void *stack_addr, int stack_size, main_t entry, FAR char * const argv[], FAR char * const envp[]); diff --git a/sched/sched/sched_processtimer.c b/sched/sched/sched_processtick.c similarity index 98% rename from sched/sched/sched_processtimer.c rename to sched/sched/sched_processtick.c index 46d2bce0b2f..7457f556bd5 100644 --- a/sched/sched/sched_processtimer.c +++ b/sched/sched/sched_processtick.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/sched/sched_processtimer.c + * sched/sched/sched_processtick.c * * SPDX-License-Identifier: Apache-2.0 * @@ -146,7 +146,7 @@ static inline void nxsched_process_scheduler(void) #endif /**************************************************************************** - * Name: nxsched_process_timer + * Name: nxsched_process_tick * * Description: * This function handles system timer events. @@ -165,7 +165,7 @@ static inline void nxsched_process_scheduler(void) * ****************************************************************************/ -void nxsched_process_timer(void) +void nxsched_process_tick(void) { #ifdef CONFIG_CLOCK_TIMEKEEPING /* Process wall time */ diff --git a/sched/sched/sched_timerexpiration.c b/sched/sched/sched_tickexpiration.c similarity index 99% rename from sched/sched/sched_timerexpiration.c rename to sched/sched/sched_tickexpiration.c index cf9f0ff0502..6e79717c2b5 100644 --- a/sched/sched/sched_timerexpiration.c +++ b/sched/sched/sched_tickexpiration.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/sched/sched_timerexpiration.c + * sched/sched/sched_tickexpiration.c * * SPDX-License-Identifier: Apache-2.0 * @@ -388,7 +388,7 @@ static clock_t nxsched_timer_start(clock_t ticks, clock_t interval) * ****************************************************************************/ -void nxsched_process_timer(void) +void nxsched_process_tick(void) { irqstate_t flags; clock_t ticks; diff --git a/sched/sched/sched_timer.c b/sched/sched/sched_timer.c new file mode 100644 index 00000000000..60913186e9d --- /dev/null +++ b/sched/sched/sched_timer.c @@ -0,0 +1,51 @@ +/**************************************************************************** + * sched/sched/sched_timer.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/arch.h> +#include <nuttx/clock.h> + +#include <errno.h> + +#include "sched/sched.h" + +/**************************************************************************** + * Name: nxsched_process_timer + * + * Description: + * Process scheduler timing events. + * + * If high-resolution timers are enabled, this function dispatches + * expired hrtimers based on the current hrtimer time. + * + * Otherwise, it falls back to directly processing a scheduler tick. + * + ****************************************************************************/ + +void nxsched_process_timer(void) +{ + nxsched_process_tick(); +}
