xiaoxiang781216 commented on code in PR #21424:
URL: https://github.com/apache/nuttx/pull/21424#discussion_r4536640090
##########
sched/sched/sched_critmonitor.c:
##########
@@ -137,49 +145,27 @@ clock_t g_busywait_total[CONFIG_SMP_NCPUS];
* Name: nxsched_critmon_cpuload
*
* Description:
- * Update the running time of all running threads when switching threads
+ * Give the running thread of a CPU the CPU load ticks since the last
+ * update of that CPU.
*
* Input Parameters:
- * tcb - The task that we are performing the load operations on.
- * current - The current time
- * tick - The ticks that we process in this cpuload.
+ * tcb - The thread that runs on the CPU.
+ * cpu - The CPU.
+ * current - The current time.
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_SCHED_CPULOAD_CRITMONITOR
-static void nxsched_critmon_cpuload(FAR struct tcb_s *tcb, clock_t current,
- clock_t tick)
+static void nxsched_critmon_cpuload(FAR struct tcb_s *tcb, int cpu,
+ clock_t current)
{
- int i;
-
- UNUSED(i);
-
- /* Update the cpuload of the thread ready to be suspended */
-
- nxsched_process_taskload_ticks(tcb, tick);
+ clock_t elapsed = current - g_cpuload_start[cpu];
- /* Update the cpuload of threads running on other CPUs */
-
-# ifdef CONFIG_SMP
- for (i = 0; i < CONFIG_SMP_NCPUS; i++)
- {
- FAR struct tcb_s *rtcb = current_task(i);
-
- if (tcb->cpu == rtcb->cpu)
- {
- continue;
- }
-
- nxsched_process_taskload_ticks(rtcb, tick);
-
- /* Update start time, avoid repeated statistics when the next call */
-
- rtcb->run_start = current;
Review Comment:
but we can subtract the current time from g_cpuload_start and then add to
run_time when the cpu switch to the new thread. so why do we still need keep
run_start?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]