Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
dda0de09
Commit
dda0de09
authored
8 years ago
by
Andreas Antener
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Load monitor: optimize performance of stack checking
parent
a74269ec
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/load_mon/load_mon.cpp
+18
-10
18 additions, 10 deletions
src/modules/load_mon/load_mon.cpp
with
18 additions
and
10 deletions
src/modules/load_mon/load_mon.cpp
+
18
−
10
View file @
dda0de09
...
...
@@ -227,12 +227,17 @@ float LoadMon::_ram_used()
#ifdef __PX4_NUTTX
void
LoadMon
::
_stack_usage
()
{
for
(
int
i
=
_stack_task_index
;
i
<
CONFIG_MAX_TASKS
;
i
++
)
{
if
(
system_load
.
tasks
[
i
].
valid
&&
system_load
.
tasks
[
i
].
tcb
->
pid
>
0
)
{
unsigned
stack_size
=
(
uintptr_t
)
system_load
.
tasks
[
i
].
tcb
->
adj_stack_ptr
-
(
uintptr_t
)
system_load
.
tasks
[
i
].
tcb
->
stack_alloc_ptr
;
int
task_index
=
0
;
/* Scan maximum 3 tasks per cycle to reduce load. */
for
(
int
i
=
_stack_task_index
;
i
<
_stack_task_index
+
3
;
i
++
)
{
task_index
=
i
%
CONFIG_MAX_TASKS
;
if
(
system_load
.
tasks
[
task_index
].
valid
&&
system_load
.
tasks
[
task_index
].
tcb
->
pid
>
0
)
{
unsigned
stack_size
=
(
uintptr_t
)
system_load
.
tasks
[
task_index
].
tcb
->
adj_stack_ptr
-
(
uintptr_t
)
system_load
.
tasks
[
task_index
].
tcb
->
stack_alloc_ptr
;
unsigned
stack_free
=
0
;
uint8_t
*
stack_sweeper
=
(
uint8_t
*
)
system_load
.
tasks
[
i
].
tcb
->
stack_alloc_ptr
;
uint8_t
*
stack_sweeper
=
(
uint8_t
*
)
system_load
.
tasks
[
task_index
].
tcb
->
stack_alloc_ptr
;
while
(
stack_free
<
stack_size
)
{
if
(
*
stack_sweeper
++
!=
0xff
)
{
...
...
@@ -246,7 +251,7 @@ void LoadMon::_stack_usage()
* Found task low on stack, report and exit. Continue here in next cycle.
*/
if
(
stack_free
<
300
)
{
strncpy
((
char
*
)
_low_stack
.
task_name
,
system_load
.
tasks
[
i
].
tcb
->
name
,
low_stack_s
::
MAX_REPORT_TASK_NAME_LEN
);
strncpy
((
char
*
)
_low_stack
.
task_name
,
system_load
.
tasks
[
task_index
].
tcb
->
name
,
low_stack_s
::
MAX_REPORT_TASK_NAME_LEN
);
_low_stack
.
stack_free
=
stack_free
;
if
(
_low_stack_pub
==
nullptr
)
{
...
...
@@ -256,14 +261,17 @@ void LoadMon::_stack_usage()
orb_publish
(
ORB_ID
(
low_stack
),
_low_stack_pub
,
&
_low_stack
);
}
// continue at next index
_stack_task_index
=
i
+
1
;
return
;
break
;
}
}
else
{
/* No task here, check one more task in same cycle. */
_stack_task_index
++
;
}
}
_stack_task_index
=
0
;
/* Continue after last checked task next cycle. */
_stack_task_index
=
task_index
+
1
;
}
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment