libCom/posix: add env var to opt out of FIFO scheduling

- add EPICS_ALLOW_POSIX_THREAD_PRIORITY_SCHEDULING
  (default: YES)
- start EPICS threads with default policy
  when set to NO
This commit is contained in:
Ralph Lange
2025-11-10 20:18:56 +01:00
committed by Andrew Johnson
parent b308be3273
commit 862272d666
3 changed files with 10 additions and 2 deletions

View File

@@ -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.

View File

@@ -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() */