From a08b54b8e157381677fb6f52779873ad69fe0c89 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Fri, 10 Jan 2020 11:02:49 -0500 Subject: [PATCH] px4_work_queue: don't inherit pthread attributes from creating thread - this is necessary on linux so that the WQ threads priorities are set relative to max, and not relative to the wq:manager thread --- platforms/common/px4_work_queue/WorkQueueManager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platforms/common/px4_work_queue/WorkQueueManager.cpp b/platforms/common/px4_work_queue/WorkQueueManager.cpp index 3125f576f8..135612ca3b 100644 --- a/platforms/common/px4_work_queue/WorkQueueManager.cpp +++ b/platforms/common/px4_work_queue/WorkQueueManager.cpp @@ -264,11 +264,20 @@ WorkQueueManagerRun(int, char **) } #ifndef __PX4_QURT + // schedule policy FIFO #if defined(ENABLE_LOCKSTEP_SCHEDULER) int ret_setschedpolicy = pthread_attr_setschedpolicy(&attr, SCHED_RR); #else + + // don't inherit attributes from parent thread + int ret_setinheritsched = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + + if (ret_setinheritsched != 0) { + PX4_ERR("failed to set inherit-scheduler attribute PTHREAD_EXPLICIT_SCHED (%i)", ret_setinheritsched); + } + int ret_setschedpolicy = pthread_attr_setschedpolicy(&attr, SCHED_FIFO); #endif