aboutsummaryrefslogtreecommitdiff
path: root/src/modules/systemlib
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-07-09 13:27:17 +0200
committerLorenz Meier <lm@inf.ethz.ch>2013-07-09 13:27:17 +0200
commit82c13efad156b1fbf0634b4d6498a95780b0c31a (patch)
treee6eb14189a575208fef69dda662dc7ddeb025d33 /src/modules/systemlib
parentd63730419b7a8ea8696f7518bf24baff149b18a3 (diff)
parente5c7ae470640ea20fe372b8da8185abf72123dbe (diff)
downloadpx4-firmware-82c13efad156b1fbf0634b4d6498a95780b0c31a.tar.gz
px4-firmware-82c13efad156b1fbf0634b4d6498a95780b0c31a.tar.bz2
px4-firmware-82c13efad156b1fbf0634b4d6498a95780b0c31a.zip
Merged CPU load changes by freddie chopin
Diffstat (limited to 'src/modules/systemlib')
-rw-r--r--src/modules/systemlib/cpuload.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/modules/systemlib/cpuload.c b/src/modules/systemlib/cpuload.c
index 8fdff8ac0..afc5b072c 100644
--- a/src/modules/systemlib/cpuload.c
+++ b/src/modules/systemlib/cpuload.c
@@ -71,8 +71,6 @@ extern FAR struct _TCB *sched_gettcb(pid_t pid);
void cpuload_initialize_once()
{
-// if (!system_load.initialized)
-// {
system_load.start_time = hrt_absolute_time();
int i;
@@ -80,27 +78,29 @@ void cpuload_initialize_once()
system_load.tasks[i].valid = false;
}
- system_load.total_count = 0;
-
uint64_t now = hrt_absolute_time();
- /* initialize idle thread statically */
- system_load.tasks[0].start_time = now;
- system_load.tasks[0].total_runtime = 0;
- system_load.tasks[0].curr_start_time = 0;
- system_load.tasks[0].tcb = sched_gettcb(0);
- system_load.tasks[0].valid = true;
- system_load.total_count++;
-
- /* initialize init thread statically */
- system_load.tasks[1].start_time = now;
- system_load.tasks[1].total_runtime = 0;
- system_load.tasks[1].curr_start_time = 0;
- system_load.tasks[1].tcb = sched_gettcb(1);
- system_load.tasks[1].valid = true;
- /* count init thread */
- system_load.total_count++;
- // }
+ int static_tasks_count = 2; // there are at least 2 threads that should be initialized statically - "idle" and "init"
+
+#ifdef CONFIG_PAGING
+ static_tasks_count++; // include paging thread in initialization
+#endif /* CONFIG_PAGING */
+#if CONFIG_SCHED_WORKQUEUE
+ static_tasks_count++; // include high priority work0 thread in initialization
+#endif /* CONFIG_SCHED_WORKQUEUE */
+#if CONFIG_SCHED_LPWORK
+ static_tasks_count++; // include low priority work1 thread in initialization
+#endif /* CONFIG_SCHED_WORKQUEUE */
+
+ // perform static initialization of "system" threads
+ for (system_load.total_count = 0; system_load.total_count < static_tasks_count; system_load.total_count++)
+ {
+ system_load.tasks[system_load.total_count].start_time = now;
+ system_load.tasks[system_load.total_count].total_runtime = 0;
+ system_load.tasks[system_load.total_count].curr_start_time = 0;
+ system_load.tasks[system_load.total_count].tcb = sched_gettcb(system_load.total_count); // it is assumed that these static threads have consecutive PIDs
+ system_load.tasks[system_load.total_count].valid = true;
+ }
}
void sched_note_start(FAR struct tcb_s *tcb)