From 9b3feee6eeaa7f49c35f239ef9b631dde02235f4 Mon Sep 17 00:00:00 2001 From: Eric Katzfey <53063038+katzfey@users.noreply.github.com> Date: Mon, 12 Dec 2022 11:25:28 -0800 Subject: [PATCH] worker and HRT threads for Qurt platform (#20739) * Getting work manager and hrt threads ready for Qurt platform --- platforms/common/include/px4_platform_common/posix.h | 7 +++++++ platforms/common/px4_work_queue/WorkQueueManager.cpp | 8 +------- platforms/common/work_queue/hrt_thread.c | 1 - 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/platforms/common/include/px4_platform_common/posix.h b/platforms/common/include/px4_platform_common/posix.h index 40024a18ec..e4d6399190 100644 --- a/platforms/common/include/px4_platform_common/posix.h +++ b/platforms/common/include/px4_platform_common/posix.h @@ -104,6 +104,13 @@ typedef struct { // Qurt has no fsync implementation so need to declare one here // and then define a fake one in the Qurt platform code. void fsync(int fd); +// Qurt doesn't have a way to set the scheduler policy. It is always, essentially, +// SCHED_FIFO. So have to add a fake function for the code that tries to set it. +#include +__EXPORT int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy); +// Qurt POSIX implementation doesn't define the SIGCONT signal so we just map it +// to a reasonable alternative +#define SIGCONT SIGALRM #endif __EXPORT int px4_open(const char *path, int flags, ...); diff --git a/platforms/common/px4_work_queue/WorkQueueManager.cpp b/platforms/common/px4_work_queue/WorkQueueManager.cpp index 3852215b29..8d961c14b3 100644 --- a/platforms/common/px4_work_queue/WorkQueueManager.cpp +++ b/platforms/common/px4_work_queue/WorkQueueManager.cpp @@ -267,9 +267,7 @@ WorkQueueManagerRun(int, char **) // create new work queue // stack size -#if defined(__PX4_QURT) - const size_t stacksize = math::max(8 * 1024, PX4_STACK_ADJUSTED(wq->stacksize)); -#elif defined(__PX4_NUTTX) +#if defined(__PX4_NUTTX) || defined(__PX4_QURT) const size_t stacksize = math::max(PTHREAD_STACK_MIN, PX4_STACK_ADJUSTED(wq->stacksize)); #elif defined(__PX4_POSIX) // On posix system , the desired stacksize round to the nearest multiplier of the system pagesize @@ -304,8 +302,6 @@ WorkQueueManagerRun(int, char **) PX4_ERR("getting sched param for %s failed (%i)", wq->name, ret_getschedparam); } -#ifndef __PX4_QURT - // schedule policy FIFO int ret_setschedpolicy = pthread_attr_setschedpolicy(&attr, SCHED_FIFO); @@ -313,8 +309,6 @@ WorkQueueManagerRun(int, char **) PX4_ERR("failed to set sched policy SCHED_FIFO (%i)", ret_setschedpolicy); } -#endif // ! QuRT - // priority param.sched_priority = sched_priority; int ret_setschedparam = pthread_attr_setschedparam(&attr, ¶m); diff --git a/platforms/common/work_queue/hrt_thread.c b/platforms/common/work_queue/hrt_thread.c index 9465f0d9f2..c0e5128790 100644 --- a/platforms/common/work_queue/hrt_thread.c +++ b/platforms/common/work_queue/hrt_thread.c @@ -293,4 +293,3 @@ void hrt_work_queue_init(void) signal(SIGCONT, _sighandler); #endif } -