sched: Simplify the cpuload process
1.Forward nxsched_process_cpuload to nxsched_process_cpuload_ticks directly 2.Define the dummy nxsched_process_cpuload_ticks when CPULOAD isn't enabled 3.Remove the weak attribute from nxsched_process_cpuload_ticks Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
95d91ef906
commit
27e8d058e7
@ -2231,31 +2231,6 @@ void nxsched_timer_expiration(void);
|
||||
void nxsched_alarm_expiration(FAR const struct timespec *ts);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_process_cpuload
|
||||
*
|
||||
* Description:
|
||||
* Collect data that can be used for CPU load measurements. When
|
||||
* CONFIG_SCHED_CPULOAD_EXTCLK is defined, this is an exported interface,
|
||||
* use the the external clock logic. Otherwise, it is an OS internal
|
||||
* interface.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* This function is called from a timer interrupt handler with all
|
||||
* interrupts disabled.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SCHED_CPULOAD) && defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
void weak_function nxsched_process_cpuload(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_process_cpuload_ticks
|
||||
*
|
||||
@ -2278,7 +2253,8 @@ void weak_function nxsched_process_cpuload(void);
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SCHED_CPULOAD) && defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
void weak_function nxsched_process_cpuload_ticks(uint32_t ticks);
|
||||
void nxsched_process_cpuload_ticks(uint32_t ticks);
|
||||
# define nxsched_process_cpuload() nxsched_process_cpuload_ticks(1)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -821,7 +821,7 @@ config SCHED_CPULOAD_EXTCLK
|
||||
achieved. This option enables use of such an "external" clock. The
|
||||
implementation of the clock must be provided by platform-specific
|
||||
logic; that platform-specific logic must call the system function
|
||||
nxsched_process_cpuload() at each timer expiration with interrupts
|
||||
nxsched_process_cpuload_ticks() at each timer expiration with interrupts
|
||||
disabled.
|
||||
|
||||
if SCHED_CPULOAD_EXTCLK
|
||||
|
@ -386,11 +386,17 @@ int nxsched_pause_cpu(FAR struct tcb_s *tcb);
|
||||
# define nxsched_islocked_tcb(tcb) ((tcb)->lockcount > 0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SCHED_CPULOAD) && !defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
#ifndef CONFIG_SCHED_CPULOAD_EXTCLK
|
||||
|
||||
/* CPU load measurement support */
|
||||
|
||||
void weak_function nxsched_process_cpuload(void);
|
||||
void weak_function nxsched_process_cpuload_ticks(uint32_t ticks);
|
||||
# ifdef CONFIG_SCHED_CPULOAD
|
||||
void nxsched_process_cpuload_ticks(uint32_t ticks);
|
||||
# else
|
||||
# define nxsched_process_cpuload_ticks(ticks)
|
||||
# endif
|
||||
|
||||
# define nxsched_process_cpuload() nxsched_process_cpuload_ticks(1)
|
||||
#endif
|
||||
|
||||
/* Critical section monitor */
|
||||
|
@ -122,32 +122,6 @@ static inline void nxsched_cpu_process_cpuload(int cpu, uint32_t ticks)
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_process_cpuload
|
||||
*
|
||||
* Description:
|
||||
* Collect data that can be used for CPU load measurements. When
|
||||
* CONFIG_SCHED_CPULOAD_EXTCLK is defined, this is an exported interface,
|
||||
* use the the external clock logic. Otherwise, it is an OS Internal
|
||||
* interface.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* This function is called from a timer interrupt handler with all
|
||||
* interrupts disabled.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void weak_function nxsched_process_cpuload(void)
|
||||
{
|
||||
nxsched_process_cpuload_ticks(1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_process_cpuload_ticks
|
||||
*
|
||||
@ -169,7 +143,7 @@ void weak_function nxsched_process_cpuload(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void weak_function nxsched_process_cpuload_ticks(uint32_t ticks)
|
||||
void nxsched_process_cpuload_ticks(uint32_t ticks)
|
||||
{
|
||||
int i;
|
||||
irqstate_t flags;
|
||||
|
@ -226,12 +226,7 @@ static void nxsched_oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
|
||||
{
|
||||
/* Perform CPU load measurements */
|
||||
|
||||
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
if (nxsched_process_cpuload != NULL)
|
||||
#endif
|
||||
{
|
||||
nxsched_process_cpuload();
|
||||
}
|
||||
nxsched_process_cpuload();
|
||||
|
||||
/* Then restart the oneshot */
|
||||
|
||||
|
@ -187,12 +187,7 @@ static bool nxsched_period_callback(FAR uint32_t *next_interval_us,
|
||||
|
||||
/* Perform CPU load measurements */
|
||||
|
||||
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
if (nxsched_process_cpuload != NULL)
|
||||
#endif
|
||||
{
|
||||
nxsched_process_cpuload();
|
||||
}
|
||||
nxsched_process_cpuload();
|
||||
|
||||
/* Then continue the timing */
|
||||
|
||||
|
@ -225,18 +225,11 @@ void nxsched_process_timer(void)
|
||||
clock_timer();
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SCHED_CPULOAD) && !defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
/* Perform CPU load measurements (before any timer-initiated context
|
||||
* switches can occur)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
if (nxsched_process_cpuload != NULL)
|
||||
#endif
|
||||
{
|
||||
nxsched_process_cpuload();
|
||||
}
|
||||
#endif
|
||||
nxsched_process_cpuload();
|
||||
|
||||
/* Check if the currently executing task has exceeded its
|
||||
* timeslice.
|
||||
|
@ -382,18 +382,11 @@ static unsigned int nxsched_timer_process(unsigned int ticks,
|
||||
clock_update_wall_time();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SCHED_CPULOAD) && !defined(CONFIG_SCHED_CPULOAD_EXTCLK)
|
||||
/* Perform CPU load measurements (before any timer-initiated context
|
||||
* switches can occur)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_HAVE_WEAKFUNCTIONS
|
||||
if (nxsched_process_cpuload_ticks != NULL)
|
||||
#endif
|
||||
{
|
||||
nxsched_process_cpuload_ticks(ticks);
|
||||
}
|
||||
#endif
|
||||
nxsched_process_cpuload_ticks(ticks);
|
||||
|
||||
/* Process watchdogs */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user