px4_work_queue: revert inherited sched attr and run wq:manager and max priority

Setting PTHREAD_EXPLICIT_SCHED was necessary on linux to create WQ threads with priorities relative to max, but unfortunately we can't rely pthread_attr_setinheritsched as it's dependent on system ulimit configuration or running privileged. Instead we can create the wq:manager at the maximum desired priority and allow each WQ thread to have a relative priority.
This commit is contained in:
Daniel Agar
2020-01-10 17:57:51 -05:00
committed by GitHub
parent 3527870333
commit bd111c9f42
2 changed files with 13 additions and 21 deletions
@@ -270,14 +270,6 @@ WorkQueueManagerRun(int, char **)
#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
@@ -327,7 +319,7 @@ WorkQueueManagerStart()
int task_id = px4_task_spawn_cmd("wq:manager",
SCHED_DEFAULT,
PX4_WQ_HP_BASE,
SCHED_PRIORITY_MAX,
1280,
(px4_main_t)&WorkQueueManagerRun,
nullptr);