From fd2da7f4bc139313f8deece8dc077b363ecf0e75 Mon Sep 17 00:00:00 2001 From: ligd Date: Fri, 29 Dec 2023 14:31:27 +0800 Subject: [PATCH] cpuload: change cpuload type to clock_t Signed-off-by: ligd --- fs/procfs/fs_procfscpuload.c | 4 ++-- include/nuttx/clock.h | 4 ++-- include/nuttx/sched.h | 2 +- sched/sched/sched.h | 6 +++--- sched/sched/sched_cpuload.c | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/procfs/fs_procfscpuload.c b/fs/procfs/fs_procfscpuload.c index 6c55e3e0bd..0742d340d8 100644 --- a/fs/procfs/fs_procfscpuload.c +++ b/fs/procfs/fs_procfscpuload.c @@ -203,8 +203,8 @@ static ssize_t cpuload_read(FAR struct file *filep, FAR char *buffer, if (filep->f_pos == 0) { - uint32_t total = 0; - uint32_t active = 0; + clock_t total = 0; + clock_t active = 0; uint32_t intpart; uint32_t fracpart; diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index 76ed107912..e329fc2402 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -277,8 +277,8 @@ #ifndef CONFIG_SCHED_CPULOAD_NONE struct cpuload_s { - volatile uint32_t total; /* Total number of clock ticks */ - volatile uint32_t active; /* Number of ticks while this thread was active */ + volatile clock_t total; /* Total number of clock ticks */ + volatile clock_t active; /* Number of ticks while this thread was active */ }; #endif diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index beb202e5f4..16e66ccc0a 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -623,7 +623,7 @@ struct tcb_s /* CPU load monitoring support ********************************************/ #ifndef CONFIG_SCHED_CPULOAD_NONE - uint32_t ticks; /* Number of ticks on this thread */ + clock_t ticks; /* Number of ticks on this thread */ #endif /* Pre-emption monitor support ********************************************/ diff --git a/sched/sched/sched.h b/sched/sched/sched.h index ceefc2b8c2..9057f86f91 100644 --- a/sched/sched/sched.h +++ b/sched/sched/sched.h @@ -240,7 +240,7 @@ extern const struct tasklist_s g_tasklisttable[NUM_TASK_STATES]; * 'denominator' for all CPU load calculations. */ -extern volatile uint32_t g_cpuload_total; +extern volatile clock_t g_cpuload_total; #endif /* Declared in sched_lock.c *************************************************/ @@ -399,8 +399,8 @@ int nxsched_pause_cpu(FAR struct tcb_s *tcb); #if defined(CONFIG_SCHED_CPULOAD_SYSCLK) || \ defined (CONFIG_SCHED_CPULOAD_CRITMONITOR) -void nxsched_process_taskload_ticks(FAR struct tcb_s *tcb, uint32_t ticks); -void nxsched_process_cpuload_ticks(uint32_t ticks); +void nxsched_process_taskload_ticks(FAR struct tcb_s *tcb, clock_t ticks); +void nxsched_process_cpuload_ticks(clock_t ticks); #define nxsched_process_cpuload() nxsched_process_cpuload_ticks(1) #endif diff --git a/sched/sched/sched_cpuload.c b/sched/sched/sched_cpuload.c index a72b0bbf2f..6d46b387d1 100644 --- a/sched/sched/sched_cpuload.c +++ b/sched/sched/sched_cpuload.c @@ -76,7 +76,7 @@ * each would have a load of 25% of the total. */ -volatile uint32_t g_cpuload_total; +volatile clock_t g_cpuload_total; /**************************************************************************** * Public Functions @@ -97,7 +97,7 @@ volatile uint32_t g_cpuload_total; * ****************************************************************************/ -void nxsched_process_taskload_ticks(FAR struct tcb_s *tcb, uint32_t ticks) +void nxsched_process_taskload_ticks(FAR struct tcb_s *tcb, clock_t ticks) { tcb->ticks += ticks; g_cpuload_total += ticks; @@ -147,7 +147,7 @@ void nxsched_process_taskload_ticks(FAR struct tcb_s *tcb, uint32_t ticks) * ****************************************************************************/ -void nxsched_process_cpuload_ticks(uint32_t ticks) +void nxsched_process_cpuload_ticks(clock_t ticks) { int i;