Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Baitboat
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
Baitboat
Commits
024d3b71
Commit
024d3b71
authored
10 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
HAL_Linux: use a semaphore in suspend_timer_procs()
this is the start of multi-core aware code
parent
dcdb5358
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/AP_HAL_Linux/Scheduler.cpp
+15
-22
15 additions, 22 deletions
libraries/AP_HAL_Linux/Scheduler.cpp
libraries/AP_HAL_Linux/Scheduler.h
+3
-2
3 additions, 2 deletions
libraries/AP_HAL_Linux/Scheduler.h
with
18 additions
and
24 deletions
libraries/AP_HAL_Linux/Scheduler.cpp
+
15
−
22
View file @
024d3b71
...
...
@@ -198,19 +198,14 @@ void LinuxScheduler::register_timer_failsafe(AP_HAL::Proc failsafe, uint32_t per
void
LinuxScheduler
::
suspend_timer_procs
()
{
_timer_suspended
=
true
;
while
(
_in_timer_proc
)
{
delay_microseconds
(
20
);
if
(
!
_timer_semaphore
.
take
(
0
))
{
printf
(
"Failed to take timer semaphore
\n
"
);
}
}
void
LinuxScheduler
::
resume_timer_procs
()
{
_timer_suspended
=
false
;
if
(
_timer_event_missed
==
true
)
{
_run_timers
(
false
);
_timer_event_missed
=
false
;
}
_timer_semaphore
.
give
();
}
void
LinuxScheduler
::
_run_timers
(
bool
called_from_timer_thread
)
...
...
@@ -220,16 +215,16 @@ void LinuxScheduler::_run_timers(bool called_from_timer_thread)
}
_in_timer_proc
=
true
;
if
(
!
_timer_suspended
)
{
// now call the timer based drivers
for
(
int
i
=
0
;
i
<
_num_timer_procs
;
i
++
)
{
if
(
_timer_proc
[
i
]
!=
NULL
)
{
_timer_proc
[
i
]();
}
if
(
!
_timer_semaphore
.
take
(
0
))
{
printf
(
"Failed to take timer semaphore in _run_timers
\n
"
);
}
// now call the timer based drivers
for
(
int
i
=
0
;
i
<
_num_timer_procs
;
i
++
)
{
if
(
_timer_proc
[
i
]
!=
NULL
)
{
_timer_proc
[
i
]();
}
}
else
if
(
called_from_timer_thread
)
{
_timer_event_missed
=
true
;
}
_timer_semaphore
.
give
();
// and the failsafe, if one is setup
if
(
_failsafe
!=
NULL
)
{
...
...
@@ -272,12 +267,10 @@ void LinuxScheduler::_run_io(void)
}
_in_io_proc
=
true
;
if
(
!
_timer_suspended
)
{
// now call the IO based drivers
for
(
int
i
=
0
;
i
<
_num_io_procs
;
i
++
)
{
if
(
_io_proc
[
i
]
!=
NULL
)
{
_io_proc
[
i
]();
}
// now call the IO based drivers
for
(
int
i
=
0
;
i
<
_num_io_procs
;
i
++
)
{
if
(
_io_proc
[
i
]
!=
NULL
)
{
_io_proc
[
i
]();
}
}
...
...
This diff is collapsed.
Click to expand it.
libraries/AP_HAL_Linux/Scheduler.h
+
3
−
2
View file @
024d3b71
...
...
@@ -3,6 +3,7 @@
#define __AP_HAL_LINUX_SCHEDULER_H__
#include
<AP_HAL_Linux.h>
#include
"Semaphores.h"
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#include
<sys/time.h>
...
...
@@ -56,8 +57,6 @@ private:
bool
_initialized
;
volatile
bool
_timer_pending
;
volatile
bool
_timer_suspended
;
AP_HAL
::
MemberProc
_timer_proc
[
LINUX_SCHEDULER_MAX_TIMER_PROCS
];
uint8_t
_num_timer_procs
;
volatile
bool
_in_timer_proc
;
...
...
@@ -83,6 +82,8 @@ private:
void
_setup_realtime
(
uint32_t
size
);
uint64_t
stopped_clock_usec
;
LinuxSemaphore
_timer_semaphore
;
};
#endif // CONFIG_HAL_BOARD
...
...
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