libCom/osi: (posix) make getOssPriorityValue() public as epicsThreadGetPosixPriority()

This commit is contained in:
Ralph Lange
2012-09-20 21:55:32 +02:00
parent 047bdc9200
commit ca441a2a0e
3 changed files with 10 additions and 5 deletions

View File

@@ -39,6 +39,7 @@ typedef struct epicsThreadOSD {
} epicsThreadOSD;
epicsShareFunc pthread_t epicsThreadGetPosixThreadId(epicsThreadId id);
epicsShareFunc int epicsThreadGetPosixPriority(epicsThreadId id);
#ifdef __cplusplus
}

View File

@@ -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,7 @@ 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);
@@ -611,7 +614,7 @@ 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");

View File

@@ -38,6 +38,7 @@ typedef struct epicsThreadOSD {
} epicsThreadOSD;
epicsShareFunc pthread_t epicsThreadGetPosixThreadId(epicsThreadId id);
epicsShareFunc int epicsThreadGetPosixPriority(epicsThreadId id);
#ifdef __cplusplus
}