Created
January 15, 2016 23:23
-
-
Save lucasdemarchi/29b604085768ed384289 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libraries/AP_HAL/Scheduler.h b/libraries/AP_HAL/Scheduler.h | |
index a22a4c0..ecf3856 100644 | |
--- a/libraries/AP_HAL/Scheduler.h | |
+++ b/libraries/AP_HAL/Scheduler.h | |
@@ -37,7 +37,10 @@ public: | |
// register a high priority timer task | |
virtual void register_timer_process(AP_HAL::MemberProc) = 0; | |
virtual bool register_timer_process(AP_HAL::MemberProc proc, uint8_t freq_div) | |
- {register_timer_process(proc); return false;} | |
+ { | |
+ register_timer_process(proc); | |
+ return false; | |
+ } | |
// register a low priority IO task | |
virtual void register_io_process(AP_HAL::MemberProc) = 0; | |
diff --git a/libraries/AP_HAL_Linux/Scheduler.cpp b/libraries/AP_HAL_Linux/Scheduler.cpp | |
index 64dab96..f7d2de1 100644 | |
--- a/libraries/AP_HAL_Linux/Scheduler.cpp | |
+++ b/libraries/AP_HAL_Linux/Scheduler.cpp | |
@@ -9,13 +9,13 @@ | |
#include "Util.h" | |
#include "SPIUARTDriver.h" | |
#include "RPIOUARTDriver.h" | |
+#include <algorithm> | |
#include <poll.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <errno.h> | |
#include <sys/mman.h> | |
-#include <iostream> | |
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_QFLIGHT | |
#include <rpcmem.h> | |
@@ -52,11 +52,9 @@ extern const AP_HAL::HAL& hal; | |
#endif // CONFIG_HAL_BOARD_SUBTYPE | |
-Scheduler::Scheduler() : | |
- _num_timer_procs(0), | |
- _num_timesliced_procs(0), | |
- _max_freq_div(0), | |
- _timeslices_count(0) | |
+ | |
+ | |
+Scheduler::Scheduler() | |
{} | |
void Scheduler::_create_realtime_thread(pthread_t *ctx, int rtprio, | |
@@ -202,16 +200,13 @@ bool Scheduler::register_timer_process(AP_HAL::MemberProc proc, | |
uint8_t freq_div) | |
{ | |
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP | |
- if (freq_div <= 1) { | |
- register_timer_process(proc); | |
- return false; | |
- } else { | |
+ if (freq_div > 1) { | |
return _register_timesliced_proc(proc, freq_div); | |
} | |
-#else | |
+ /* fallback to normal timer process */ | |
+#endif | |
register_timer_process(proc); | |
return false; | |
-#endif | |
} | |
bool Scheduler::_register_timesliced_proc(AP_HAL::MemberProc proc, | |
@@ -326,7 +321,7 @@ void Scheduler::_run_timers(bool called_from_timer_thread) | |
for (i = 0; i < _num_timesliced_procs; i++) { | |
if ((_timeslices_count + _timesliced_proc[i].timeslot) | |
- % _timesliced_proc[i].freq_div == 0) { | |
+ % _timesliced_proc[i].freq_div == 0) { | |
_timesliced_proc[i].proc(); | |
} | |
} | |
diff --git a/libraries/AP_HAL_Linux/Scheduler.h b/libraries/AP_HAL_Linux/Scheduler.h | |
index 6109173..bf7e35a 100644 | |
--- a/libraries/AP_HAL_Linux/Scheduler.h | |
+++ b/libraries/AP_HAL_Linux/Scheduler.h | |
@@ -69,8 +69,7 @@ private: | |
volatile bool _in_timer_proc; | |
uint8_t _timeslices_count; | |
- class timesliced_proc { | |
- public: | |
+ struct timesliced_proc { | |
AP_HAL::MemberProc proc; | |
uint8_t timeslot; | |
uint8_t freq_div; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment