diff --git a/configure/CONFIG_ENV b/configure/CONFIG_ENV index 6d0d52a79..3ec50c020 100644 --- a/configure/CONFIG_ENV +++ b/configure/CONFIG_ENV @@ -53,3 +53,5 @@ EPICS_IOC_IGNORE_SERVERS="" # EPICS_IOC_LOG_PORT Log server port number etc. EPICS_IOC_LOG_PORT=7004 +# Posix priority scheduling +EPICS_ALLOW_POSIX_THREAD_PRIORITY_SCHEDULING=YES diff --git a/modules/libcom/src/env/envDefs.h b/modules/libcom/src/env/envDefs.h index c6421374f..bd0212a6f 100644 --- a/modules/libcom/src/env/envDefs.h +++ b/modules/libcom/src/env/envDefs.h @@ -77,6 +77,7 @@ LIBCOM_API extern const ENV_PARAM IOCSH_PS1; LIBCOM_API extern const ENV_PARAM IOCSH_HISTSIZE; LIBCOM_API extern const ENV_PARAM IOCSH_HISTEDIT_DISABLE; LIBCOM_API extern const ENV_PARAM EPICS_ABORT_ON_ASSERT; +LIBCOM_API extern const ENV_PARAM EPICS_ALLOW_POSIX_THREAD_PRIORITY_SCHEDULING; /** @brief List of all parameters. * * A NULL terminated array of all ENV_PARAM known to EPICS Base. diff --git a/modules/libcom/src/osi/os/posix/osdThread.c b/modules/libcom/src/osi/os/posix/osdThread.c index 49754c0fd..4839c8b19 100644 --- a/modules/libcom/src/osi/os/posix/osdThread.c +++ b/modules/libcom/src/osi/os/posix/osdThread.c @@ -50,6 +50,7 @@ #include "epicsAssert.h" #include "epicsExit.h" #include "epicsAtomic.h" +#include "envDefs.h" LIBCOM_API void epicsThreadShowInfo(epicsThreadOSD *pthreadInfo, unsigned int level); LIBCOM_API void osdThreadHooksRun(epicsThreadId id); @@ -93,6 +94,7 @@ static pthread_mutex_t listLock; static ELLLIST pthreadList = ELLLIST_INIT; static commonAttr *pcommonAttr = 0; static int epicsThreadOnceCalled = 0; +static int wantPrioScheduling = 0; static epicsThreadOSD *createImplicit(void); @@ -384,6 +386,7 @@ static void once(void) checkStatusOnce(status,"pthread_attr_getschedparam"); findPriorityRange(pcommonAttr); + envGetBoolConfigParam(&EPICS_ALLOW_POSIX_THREAD_PRIORITY_SCHEDULING, &wantPrioScheduling); if(pcommonAttr->maxPriority == -1) { pcommonAttr->maxPriority = pcommonAttr->schedParam.sched_priority; @@ -604,8 +607,10 @@ epicsThreadCreateOpt(const char * name, return 0; pthreadInfo->isEpicsThread = 1; - setSchedulingPolicy(pthreadInfo, SCHED_FIFO); - pthreadInfo->isRealTimeScheduled = 1; + if (wantPrioScheduling) { + setSchedulingPolicy(pthreadInfo, SCHED_FIFO); + pthreadInfo->isRealTimeScheduled = 1; + } if (pthreadInfo->joinable) { /* extra ref for epicsThreadMustJoin() */