mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 18:27:05 +08:00
LoadMon:Support NuttX Dynamic FDs
This commit is contained in:
committed by
Daniel Agar
parent
4353d0faf3
commit
069130403d
@@ -242,7 +242,6 @@ void LoadMon::cpuload()
|
|||||||
void LoadMon::stack_usage()
|
void LoadMon::stack_usage()
|
||||||
{
|
{
|
||||||
unsigned stack_free = 0;
|
unsigned stack_free = 0;
|
||||||
unsigned fds_free = FDS_LOW_WARNING_THRESHOLD + 1;
|
|
||||||
|
|
||||||
bool checked_task = false;
|
bool checked_task = false;
|
||||||
|
|
||||||
@@ -261,22 +260,19 @@ void LoadMon::stack_usage()
|
|||||||
|
|
||||||
checked_task = true;
|
checked_task = true;
|
||||||
|
|
||||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
#if CONFIG_NFILE_DESCRIPTORS_PER_BLOCK > 0
|
||||||
FAR struct task_group_s *group = system_load.tasks[_stack_task_index].tcb->group;
|
unsigned int tcb_num_used_fds = 0; // number of used file descriptors
|
||||||
|
struct filelist *filelist = &system_load.tasks[_stack_task_index].tcb->group->tg_filelist;
|
||||||
|
|
||||||
unsigned tcb_num_used_fds = 0;
|
for (int fdr = 0; fdr < filelist->fl_rows; fdr++) {
|
||||||
|
for (int fdc = 0; fdc < CONFIG_NFILE_DESCRIPTORS_PER_BLOCK; fdc++) {
|
||||||
if (group) {
|
if (filelist->fl_files[fdr][fdc].f_inode) {
|
||||||
for (int fd_index = 0; fd_index < CONFIG_NFILE_DESCRIPTORS; ++fd_index) {
|
|
||||||
if (group->tg_filelist.fl_files[fd_index].f_inode) {
|
|
||||||
++tcb_num_used_fds;
|
++tcb_num_used_fds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fds_free = CONFIG_NFILE_DESCRIPTORS - tcb_num_used_fds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_NFILE_DESCRIPTORS
|
#endif // CONFIG_NFILE_DESCRIPTORS_PER_BLOCK
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
@@ -291,11 +287,6 @@ void LoadMon::stack_usage()
|
|||||||
if (stack_free < STACK_LOW_WARNING_THRESHOLD) {
|
if (stack_free < STACK_LOW_WARNING_THRESHOLD) {
|
||||||
PX4_WARN("%s low on stack! (%i bytes left)", task_stack_info.task_name, stack_free);
|
PX4_WARN("%s low on stack! (%i bytes left)", task_stack_info.task_name, stack_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Found task low on file descriptors, report and exit. Continue here in next cycle.
|
|
||||||
if (fds_free < FDS_LOW_WARNING_THRESHOLD) {
|
|
||||||
PX4_WARN("%s low on FDs! (%i FDs left)", task_stack_info.task_name, fds_free);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue after last checked task next cycle
|
// Continue after last checked task next cycle
|
||||||
|
|||||||
Reference in New Issue
Block a user