undef _POSIX options; minor changes

This commit is contained in:
Marty Kraimer
2000-10-06 13:33:52 +00:00
parent 8b8b4a736d
commit 9f884c0641
2 changed files with 31 additions and 19 deletions

View File

@@ -22,9 +22,14 @@ of this distribution.
#include "cantProceed.h"
#include "tsStamp.h"
#include "errlog.h"
#include "epicsAssert.h"
/* Until these can be demonstrated to work leave them undefined*/
#undef _POSIX_THREAD_PROCESS_SHARED
#undef _POSIX_THREAD_PRIO_INHERIT
typedef struct binary {
pthread_mutex_t mutex;
pthread_mutex_t mutex;
pthread_cond_t cond;
int isFull;
}binary;
@@ -33,9 +38,9 @@ typedef struct mutex {
pthread_mutexattr_t mutexAttr;
pthread_mutex_t lock;
pthread_cond_t waitToBeOwner;
#ifdef _POSIX_THREAD_PROCESS_SHARED
#if defined _POSIX_THREAD_PROCESS_SHARED
pthread_condattr_t condAttr;
#endif
#endif /*_POSIX_THREAD_PROCESS_SHARED*/
int count;
int owned; /* TRUE | FALSE */
pthread_t ownerTid;
@@ -127,6 +132,7 @@ semTakeStatus semBinaryTake(semBinaryId id)
if(!pbinary) return(semTakeError);
status = pthread_mutex_lock(&pbinary->mutex);
checkStatusQuit(status,"pthread_mutex_lock","semBinaryTake");
/*no need for while since caller must be prepared for no work*/
if(!pbinary->isFull) {
status = pthread_cond_wait(&pbinary->cond,&pbinary->mutex);
checkStatusQuit(status,"pthread_cond_wait","semBinaryTake");
@@ -176,14 +182,14 @@ semMutexId semMutexCreate(void) {
pmutex = callocMustSucceed(1,sizeof(mutex),"semMutexCreate");
status = pthread_mutexattr_init(&pmutex->mutexAttr);
checkStatusQuit(status,"pthread_mutexattr_init","semMutexCreate");
#ifdef _POSIX_THREAD_PRIO_INHERIT
#if defined _POSIX_THREAD_PRIO_INHERIT
status = pthread_mutexattr_setprotocol(
&pmutex->mutexAttr,PTHREAD_PRIO_INHERIT);
if(errVerbose) checkStatus(status,"pthread_mutexattr_setprotocal");
#endif
#endif /*_POSIX_THREAD_PRIO_INHERIT*/
status = pthread_mutex_init(&pmutex->lock,&pmutex->mutexAttr);
checkStatusQuit(status,"pthread_mutex_init","semMutexCreate");
#ifdef _POSIX_THREAD_PROCESS_SHARED
#if defined _POSIX_THREAD_PROCESS_SHARED
status = pthread_condattr_init(&pmutex->condAttr);
checkStatus(status,"pthread_condattr_init");
status = pthread_condattr_setpshared(&pmutex->condAttr,
@@ -192,7 +198,7 @@ semMutexId semMutexCreate(void) {
status = pthread_cond_init(&pmutex->waitToBeOwner,&pmutex->condAttr);
#else
status = pthread_cond_init(&pmutex->waitToBeOwner,0);
#endif
#endif /*_POSIX_THREAD_PROCESS_SHARED*/
checkStatusQuit(status,"pthread_cond_init","semMutexCreate");
return((semMutexId)pmutex);
}
@@ -211,6 +217,9 @@ void semMutexDestroy(semMutexId id)
status = pthread_cond_destroy(&pmutex->waitToBeOwner);
checkStatus(status,"pthread_cond_destroy");
#if defined _POSIX_THREAD_PROCESS_SHARED
status = pthread_condattr_destroy(&pmutex->condAttr);
#endif /*_POSIX_THREAD_PROCESS_SHARED*/
status = pthread_mutex_destroy(&pmutex->lock);
checkStatus(status,"pthread_mutex_destroy");
status = pthread_mutexattr_destroy(&pmutex->mutexAttr);
@@ -221,7 +230,7 @@ void semMutexDestroy(semMutexId id)
void semMutexGive(semMutexId id)
{
mutex *pmutex = (mutex *)id;
int status,unlockStatus;
int status;
status = pthread_mutex_lock(&pmutex->lock);
checkStatusQuit(status,"pthread_mutex_lock","semMutexGive");

View File

@@ -25,6 +25,11 @@ of this distribution.
#include "osiSem.h"
#include "cantProceed.h"
#include "errlog.h"
#include "epicsAssert.h"
/* Until these can be demonstrated to work leave them undefined*/
#undef _POSIX_THREAD_ATTR_STACKSIZE
#undef _POSIX_THREAD_PRIORITY_SCHEDULING
typedef struct commonAttr{
pthread_attr_t attr;
@@ -137,9 +142,7 @@ static threadInfo * init_threadInfo(const char *name,
&pthreadInfo->attr, PTHREAD_CREATE_DETACHED);
if(errVerbose) checkStatusOnce(status,"pthread_attr_setdetachstate");
#if defined (_POSIX_THREAD_ATTR_STACKSIZE)
#if defined (OSITHREAD_USE_DEFAULT_STACK)
stackSize = 0;
#else
#if ! defined (OSITHREAD_USE_DEFAULT_STACK)
status = pthread_attr_setstacksize(
&pthreadInfo->attr, (size_t)stackSize);
if(errVerbose) checkStatusOnce(status,"pthread_attr_setstacksize");
@@ -265,7 +268,9 @@ static void * start_routine(void *arg)
unsigned int threadGetStackSize (threadStackSizeClass stackSizeClass)
{
#if defined (OSITHREAD_USE_DEFAULT_STACK)
#if ! defined (_POSIX_THREAD_ATTR_STACKSIZE)
return 0;
#elif defined (OSITHREAD_USE_DEFAULT_STACK)
return 0;
#else
static const unsigned stackSizeTable[threadStackBig+1] =
@@ -281,7 +286,7 @@ unsigned int threadGetStackSize (threadStackSizeClass stackSizeClass)
}
return stackSizeTable[stackSizeClass];
#endif /* OSITHREAD_USE_DEFAULT_STACK */
#endif /*_POSIX_THREAD_ATTR_STACKSIZE*/
}
void threadInit(void)
@@ -318,11 +323,7 @@ threadId threadCreate(const char *name,
int status;
if(!threadInitCalled) threadInit();
if(pcommonAttr==0) {
fprintf(stderr,"It appears that threadCreate was called before threadInit.\n");
fprintf(stderr,"Program is exiting\n");
exit(-1);
}
assert(pcommonAttr);
pthreadInfo = init_threadInfo(name,priority,stackSize,funptr,parm);
status = pthread_create(&pthreadInfo->tid,&pthreadInfo->attr,
start_routine,pthreadInfo);
@@ -371,7 +372,9 @@ unsigned int threadGetPrioritySelf(void)
void threadSetPriority(threadId id,unsigned int priority)
{
threadInfo *pthreadInfo = (threadInfo *)id;
#if defined (_POSIX_THREAD_PRIORITY_SCHEDULING)
int status;
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
pthreadInfo->osiPriority = priority;
#if defined (_POSIX_THREAD_PRIORITY_SCHEDULING)
@@ -502,7 +505,7 @@ void threadShow(threadId id,unsigned int level)
status = pthread_getschedparam(pthreadInfo->tid,&policy,&param);
priority = (status ? 0 : param.sched_priority);
printf("%16.16s %8x %p %8d %8.8s\n", pthreadInfo->name,(threadId)
printf("%16.16s %p %d %8d %8.8s\n", pthreadInfo->name,(threadId)
pthreadInfo,pthreadInfo->osiPriority,priority,pthreadInfo->
isSuspended?"SUSPEND":"OK");
if(level>0)