mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-12 06:21:35 +08:00
Fix cpuload.cpp with NuttX 10.3+
This commit is contained in:
@@ -143,5 +143,53 @@ void sched_note_stop(FAR struct tcb_s *tcb)
|
||||
}
|
||||
}
|
||||
|
||||
void sched_note_suspend(FAR struct tcb_s *tcb)
|
||||
{
|
||||
if (system_load.initialized) {
|
||||
if (tcb->pid == 0) {
|
||||
system_load.tasks[0].total_runtime += hrt_elapsed_time(&system_load.tasks[0].curr_start_time);
|
||||
return;
|
||||
|
||||
} else {
|
||||
if (cpuload_monitor_all_count.load() == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &task : system_load.tasks) {
|
||||
// Task ending its current scheduling run
|
||||
if (task.valid && (task.curr_start_time > 0)
|
||||
&& task.tcb && task.tcb->pid == tcb->pid) {
|
||||
|
||||
task.total_runtime += hrt_elapsed_time(&task.curr_start_time);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sched_note_resume(FAR struct tcb_s *tcb)
|
||||
{
|
||||
if (system_load.initialized) {
|
||||
if (tcb->pid == 0) {
|
||||
hrt_store_absolute_time(&system_load.tasks[0].curr_start_time);
|
||||
return;
|
||||
|
||||
} else {
|
||||
if (cpuload_monitor_all_count.load() == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &task : system_load.tasks) {
|
||||
if (task.valid && task.tcb && task.tcb->pid == tcb->pid) {
|
||||
// curr_start_time is accessed from an IRQ handler (in logger), so we need
|
||||
// to make the update atomic
|
||||
hrt_store_absolute_time(&task.curr_start_time);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
__END_DECLS
|
||||
#endif // PX4_NUTTX && CONFIG_SCHED_INSTRUMENTATION
|
||||
|
||||
Reference in New Issue
Block a user