From a1ef1a93185009740f31fe5e7222a4d53bbc8090 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 29 Sep 2013 10:16:07 +1000 Subject: [PATCH] HAL_Linux: tweak the scheduling priorities --- libraries/AP_HAL_Linux/Scheduler.cpp | 10 ++++++++++ libraries/AP_HAL_Linux/Scheduler.h | 5 ----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libraries/AP_HAL_Linux/Scheduler.cpp b/libraries/AP_HAL_Linux/Scheduler.cpp index 60a52c375e..6568d0f438 100644 --- a/libraries/AP_HAL_Linux/Scheduler.cpp +++ b/libraries/AP_HAL_Linux/Scheduler.cpp @@ -15,6 +15,11 @@ using namespace Linux; extern const AP_HAL::HAL& hal; +#define APM_LINUX_MAIN_PRIORITY 180 +#define APM_LINUX_TIMER_PRIORITY 182 +#define APM_LINUX_UART_PRIORITY 181 +#define APM_LINUX_IO_PRIORITY 59 + LinuxScheduler::LinuxScheduler() {} @@ -27,6 +32,11 @@ void LinuxScheduler::init(void* machtnichts) pthread_attr_t thread_attr; struct sched_param param; + memset(¶m, 0, sizeof(param)); + + param.sched_priority = APM_LINUX_MAIN_PRIORITY; + sched_setscheduler(0, SCHED_FIFO, ¶m); + param.sched_priority = APM_LINUX_TIMER_PRIORITY; pthread_attr_init(&thread_attr); (void)pthread_attr_setschedparam(&thread_attr, ¶m); diff --git a/libraries/AP_HAL_Linux/Scheduler.h b/libraries/AP_HAL_Linux/Scheduler.h index 20e58c1252..39e71e84b1 100644 --- a/libraries/AP_HAL_Linux/Scheduler.h +++ b/libraries/AP_HAL_Linux/Scheduler.h @@ -10,11 +10,6 @@ #define LINUX_SCHEDULER_MAX_TIMER_PROCS 10 -#define APM_LINUX_MAIN_PRIORITY 180 -#define APM_LINUX_TIMER_PRIORITY 181 -#define APM_LINUX_UART_PRIORITY 60 -#define APM_LINUX_IO_PRIORITY 59 - class Linux::LinuxScheduler : public AP_HAL::Scheduler { public: LinuxScheduler();