From 742b1839d517bb4ebc5a4ad9b3d292157bf68fd8 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 24 Dec 2019 12:41:51 +0100 Subject: [PATCH] Simulation: Set scheduling policy RR for lockstep This should ensure that all processes do still run at full load. --- platforms/common/px4_work_queue/WorkQueueManager.cpp | 5 +++++ platforms/posix/src/px4/common/px4_posix_tasks.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/platforms/common/px4_work_queue/WorkQueueManager.cpp b/platforms/common/px4_work_queue/WorkQueueManager.cpp index f0fb3a093c..3125f576f8 100644 --- a/platforms/common/px4_work_queue/WorkQueueManager.cpp +++ b/platforms/common/px4_work_queue/WorkQueueManager.cpp @@ -265,7 +265,12 @@ WorkQueueManagerRun(int, char **) #ifndef __PX4_QURT // schedule policy FIFO + +#if defined(ENABLE_LOCKSTEP_SCHEDULER) + int ret_setschedpolicy = pthread_attr_setschedpolicy(&attr, SCHED_RR); +#else int ret_setschedpolicy = pthread_attr_setschedpolicy(&attr, SCHED_FIFO); +#endif if (ret_setschedpolicy != 0) { PX4_ERR("failed to set sched policy SCHED_FIFO (%i)", ret_setschedpolicy); diff --git a/platforms/posix/src/px4/common/px4_posix_tasks.cpp b/platforms/posix/src/px4/common/px4_posix_tasks.cpp index d535f34e50..d0027cfa00 100644 --- a/platforms/posix/src/px4/common/px4_posix_tasks.cpp +++ b/platforms/posix/src/px4/common/px4_posix_tasks.cpp @@ -204,7 +204,11 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int return (rv < 0) ? rv : -rv; } +#if defined(ENABLE_LOCKSTEP_SCHEDULER) + rv = pthread_attr_setschedpolicy(&attr, SCHED_RR); +#else rv = pthread_attr_setschedpolicy(&attr, scheduler); +#endif if (rv != 0) { PX4_ERR("px4_task_spawn_cmd: failed to set sched policy");