This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9f44bff3cc5ce9a89207a41443a5caba6030e193 Author: wangchengdong <[email protected]> AuthorDate: Sun Jan 11 22:46:18 2026 +0800 sched/sched:merge tickless and tick process together Merge tickless and tick process into nxsched_process_timer to improve code level efficient Signed-off-by: Chengdong Wang <[email protected]> --- drivers/timers/arch_alarm.c | 2 +- include/nuttx/arch.h | 26 ------------------------- sched/sched/CMakeLists.txt | 5 ++--- sched/sched/Make.defs | 4 +--- sched/sched/sched.h | 24 +++++++++++++++++++++++ sched/sched/sched_processtimer.c | 41 ++++++++++++++++++++++++++-------------- 6 files changed, 55 insertions(+), 47 deletions(-) diff --git a/drivers/timers/arch_alarm.c b/drivers/timers/arch_alarm.c index 4f04e0d44b6..d7580662d68 100644 --- a/drivers/timers/arch_alarm.c +++ b/drivers/timers/arch_alarm.c @@ -119,7 +119,7 @@ static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower, FAR void *arg) { #ifdef CONFIG_SCHED_TICKLESS - nxsched_timer_expiration(); + nxsched_process_timer(); #else clock_t now; diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 788b4219909..8adfb659308 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -2461,33 +2461,7 @@ void up_ndelay(unsigned long nanoseconds); * ****************************************************************************/ -#ifndef CONFIG_SCHED_TICKLESS void nxsched_process_timer(void); -#endif - -/**************************************************************************** - * Name: nxsched_timer_expiration - * - * Description: - * If CONFIG_SCHED_TICKLESS is defined, then this function is provided by - * the RTOS base code and called from platform-specific code when the - * interval timer used to implement the tick-less OS expires. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - * Assumptions/Limitations: - * Base code implementation assumes that this function is called from - * interrupt handling logic with interrupts disabled. - * - ****************************************************************************/ - -#if defined(CONFIG_SCHED_TICKLESS) -void nxsched_timer_expiration(void); -#endif /**************************************************************************** * Name: nxsched_get_next_expired diff --git a/sched/sched/CMakeLists.txt b/sched/sched/CMakeLists.txt index 782234f846d..1f7d29875bb 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_processtimer.c) if(DEFINED CONFIG_STACKCHECK_MARGIN) if(NOT CONFIG_STACKCHECK_MARGIN EQUAL -1) @@ -98,8 +99,6 @@ endif() if(CONFIG_SCHED_TICKLESS) list(APPEND SRCS sched_timerexpiration.c) -else() - list(APPEND SRCS sched_processtimer.c) endif() if(CONFIG_SCHED_CRITMONITOR) diff --git a/sched/sched/Make.defs b/sched/sched/Make.defs index 71a7bc2ce6b..232408a7536 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_processtimer.c ifneq ($(CONFIG_STACKCHECK_MARGIN),) ifneq ($(CONFIG_STACKCHECK_MARGIN),-1) @@ -80,8 +80,6 @@ endif ifeq ($(CONFIG_SCHED_TICKLESS),y) CSRCS += sched_timerexpiration.c -else -CSRCS += sched_processtimer.c endif ifeq ($(CONFIG_SCHED_CRITMONITOR),y) diff --git a/sched/sched/sched.h b/sched/sched/sched.h index 3fb922585cb..55704b2e439 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -307,6 +307,30 @@ extern volatile spinlock_t g_cpu_tasklistlock; * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: nxsched_timer_expiration + * + * Description: + * If CONFIG_SCHED_TICKLESS is defined, then this function is provided by + * the RTOS base code and called from platform-specific code when the + * interval timer used to implement the tick-less OS expires. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + * Assumptions/Limitations: + * Base code implementation assumes that this function is called from + * interrupt handling logic with interrupts disabled. + * + ****************************************************************************/ + +#if defined(CONFIG_SCHED_TICKLESS) +void nxsched_timer_expiration(void); +#endif + 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_processtimer.c index 6dbf2d15509..83ebadefb10 100644 --- a/sched/sched/sched_processtimer.c +++ b/sched/sched/sched_processtimer.c @@ -49,6 +49,7 @@ * Private Functions ****************************************************************************/ +#ifndef CONFIG_SCHED_TICKLESS /**************************************************************************** * Name: nxsched_cpu_scheduler * @@ -145,19 +146,7 @@ static inline void nxsched_process_scheduler(void) #endif /**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * System Timer Hooks - * - * These are standard interfaces that are exported by the OS - * for use by the architecture specific logic - * - ****************************************************************************/ - -/**************************************************************************** - * Name: nxsched_process_timer + * Name: nxsched_process_tick * * Description: * This function handles system timer events. @@ -174,7 +163,7 @@ static inline void nxsched_process_scheduler(void) * ****************************************************************************/ -void nxsched_process_timer(void) +static void nxsched_process_tick(void) { #ifdef CONFIG_CLOCK_TIMEKEEPING /* Process wall time */ @@ -204,3 +193,27 @@ void nxsched_process_timer(void) board_timerhook(); #endif } +#endif + +/**************************************************************************** + * System Timer Hooks + * + * These are standard interfaces that are exported by the OS + * for use by the architecture specific logic + * + ****************************************************************************/ + +void nxsched_process_timer(void) +{ +#ifdef CONFIG_SCHED_TICKLESS + /* Tickless scheduling */ + + nxsched_timer_expiration(); + +#else + /* Periodic tick-based scheduling */ + + nxsched_process_tick(); + +#endif +}
