Merge libCom/osi changes needed for MultiCore Real-Time Utils
This commit is contained in:
@@ -26,6 +26,7 @@ typedef struct epicsThreadOSD {
|
||||
pid_t lwpId;
|
||||
pthread_attr_t attr;
|
||||
struct sched_param schedParam;
|
||||
int schedPolicy;
|
||||
EPICSTHREADFUNC createFunc;
|
||||
void *createArg;
|
||||
epicsEventId suspendEvent;
|
||||
@@ -38,6 +39,7 @@ typedef struct epicsThreadOSD {
|
||||
} epicsThreadOSD;
|
||||
|
||||
epicsShareFunc pthread_t epicsThreadGetPosixThreadId(epicsThreadId id);
|
||||
epicsShareFunc int epicsThreadGetPosixPriority(epicsThreadId id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -106,9 +106,9 @@ if(status) { \
|
||||
}
|
||||
|
||||
|
||||
#if defined (_POSIX_THREAD_PRIORITY_SCHEDULING)
|
||||
static int getOssPriorityValue(epicsThreadOSD *pthreadInfo)
|
||||
epicsShareFunc int epicsThreadGetPosixPriority(epicsThreadId pthreadInfo)
|
||||
{
|
||||
#if defined (_POSIX_THREAD_PRIORITY_SCHEDULING)
|
||||
double maxPriority,minPriority,slope,oss;
|
||||
|
||||
if(pcommonAttr->maxPriority==pcommonAttr->minPriority)
|
||||
@@ -118,8 +118,11 @@ static int getOssPriorityValue(epicsThreadOSD *pthreadInfo)
|
||||
slope = (maxPriority - minPriority)/100.0;
|
||||
oss = (double)pthreadInfo->osiPriority * slope + minPriority;
|
||||
return((int)oss);
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||
}
|
||||
|
||||
static void setSchedulingPolicy(epicsThreadOSD *pthreadInfo,int policy)
|
||||
{
|
||||
#if defined (_POSIX_THREAD_PRIORITY_SCHEDULING)
|
||||
@@ -128,7 +131,8 @@ static void setSchedulingPolicy(epicsThreadOSD *pthreadInfo,int policy)
|
||||
status = pthread_attr_getschedparam(
|
||||
&pthreadInfo->attr,&pthreadInfo->schedParam);
|
||||
checkStatusOnce(status,"pthread_attr_getschedparam");
|
||||
pthreadInfo->schedParam.sched_priority = getOssPriorityValue(pthreadInfo);
|
||||
pthreadInfo->schedParam.sched_priority = epicsThreadGetPosixPriority(pthreadInfo);
|
||||
pthreadInfo->schedPolicy = policy;
|
||||
status = pthread_attr_setschedpolicy(
|
||||
&pthreadInfo->attr,policy);
|
||||
checkStatusOnce(status,"pthread_attr_setschedpolicy");
|
||||
@@ -610,12 +614,12 @@ epicsShareFunc void epicsShareAPI epicsThreadSetPriority(epicsThreadId pthreadIn
|
||||
pthreadInfo->osiPriority = priority;
|
||||
if(!pthreadInfo->isRealTimeScheduled) return;
|
||||
#if defined (_POSIX_THREAD_PRIORITY_SCHEDULING)
|
||||
pthreadInfo->schedParam.sched_priority = getOssPriorityValue(pthreadInfo);
|
||||
pthreadInfo->schedParam.sched_priority = epicsThreadGetPosixPriority(pthreadInfo);
|
||||
status = pthread_attr_setschedparam(
|
||||
&pthreadInfo->attr,&pthreadInfo->schedParam);
|
||||
if(errVerbose) checkStatus(status,"pthread_attr_setschedparam");
|
||||
status = pthread_setschedparam(
|
||||
pthreadInfo->tid,pcommonAttr->schedPolicy,&pthreadInfo->schedParam);
|
||||
pthreadInfo->tid, pthreadInfo->schedPolicy, &pthreadInfo->schedParam);
|
||||
if(errVerbose) checkStatus(status,"pthread_setschedparam");
|
||||
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ typedef struct epicsThreadOSD {
|
||||
pthread_t tid;
|
||||
pthread_attr_t attr;
|
||||
struct sched_param schedParam;
|
||||
int schedPolicy;
|
||||
EPICSTHREADFUNC createFunc;
|
||||
void *createArg;
|
||||
epicsEventId suspendEvent;
|
||||
@@ -37,6 +38,7 @@ typedef struct epicsThreadOSD {
|
||||
} epicsThreadOSD;
|
||||
|
||||
epicsShareFunc pthread_t epicsThreadGetPosixThreadId(epicsThreadId id);
|
||||
epicsShareFunc int epicsThreadGetPosixPriority(epicsThreadId id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user