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
72f52c92
Commit
72f52c92
authored
8 years ago
by
Andreas Antener
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Load monitor: reduce scope of scheduler locking
parent
806b8d3a
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
+13
-5
13 additions, 5 deletions
src/modules/load_mon/load_mon.cpp
with
13 additions
and
5 deletions
src/modules/load_mon/load_mon.cpp
+
13
−
5
View file @
72f52c92
...
...
@@ -190,11 +190,7 @@ void LoadMon::_compute()
_cpuload
.
ram_usage
=
_ram_used
();
#ifdef __PX4_NUTTX
perf_begin
(
_stack_perf
);
sched_lock
();
_stack_usage
();
sched_unlock
();
perf_end
(
_stack_perf
);
#endif
if
(
_cpuload_pub
==
nullptr
)
{
...
...
@@ -242,11 +238,16 @@ void LoadMon::_stack_usage()
/* 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
;
unsigned
stack_free
=
0
;
bool
checked_task
=
false
;
perf_begin
(
_stack_perf
);
sched_lock
();
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
[
task_index
].
tcb
->
stack_alloc_ptr
;
while
(
stack_free
<
stack_size
)
{
...
...
@@ -257,6 +258,13 @@ void LoadMon::_stack_usage()
stack_free
++
;
}
checked_task
=
true
;
}
sched_unlock
();
perf_end
(
_stack_perf
);
if
(
checked_task
)
{
/*
* Found task low on stack, report and exit. Continue here in next cycle.
*/
...
...
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