Browse Source

Merged CPU load changes by freddie chopin

sbg
Lorenz Meier 12 years ago
parent
commit
82c13efad1
  1. 40
      src/modules/systemlib/cpuload.c

40
src/modules/systemlib/cpuload.c

@ -71,8 +71,6 @@ extern FAR struct _TCB *sched_gettcb(pid_t pid);
void cpuload_initialize_once() void cpuload_initialize_once()
{ {
// if (!system_load.initialized)
// {
system_load.start_time = hrt_absolute_time(); system_load.start_time = hrt_absolute_time();
int i; int i;
@ -80,27 +78,29 @@ void cpuload_initialize_once()
system_load.tasks[i].valid = false; system_load.tasks[i].valid = false;
} }
system_load.total_count = 0;
uint64_t now = hrt_absolute_time(); uint64_t now = hrt_absolute_time();
/* initialize idle thread statically */ int static_tasks_count = 2; // there are at least 2 threads that should be initialized statically - "idle" and "init"
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 */ #ifdef CONFIG_PAGING
system_load.tasks[1].start_time = now; static_tasks_count++; // include paging thread in initialization
system_load.tasks[1].total_runtime = 0; #endif /* CONFIG_PAGING */
system_load.tasks[1].curr_start_time = 0; #if CONFIG_SCHED_WORKQUEUE
system_load.tasks[1].tcb = sched_gettcb(1); static_tasks_count++; // include high priority work0 thread in initialization
system_load.tasks[1].valid = true; #endif /* CONFIG_SCHED_WORKQUEUE */
/* count init thread */ #if CONFIG_SCHED_LPWORK
system_load.total_count++; 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) void sched_note_start(FAR struct tcb_s *tcb)

Loading…
Cancel
Save