call threadInit where needed

This commit is contained in:
Marty Kraimer
2000-06-13 19:08:16 +00:00
parent ac8754459d
commit 081ceea52d
3 changed files with 7 additions and 4 deletions

View File

@@ -237,8 +237,7 @@ threadCreate (const char *name,
rtems_status_code sc;
char c[4];
if (!initialized)
badInit ("threadCreate");
if (!initialized) threadInit();
if (stackSize < RTEMS_MINIMUM_STACK_SIZE) {
errlogPrintf ("threadCreate %s illegal stackSize %d\n",name,stackSize);
return 0;
@@ -421,8 +420,7 @@ threadId threadGetId (const char *name)
*/
void threadOnceOsd(threadOnceId *id, void(*func)(void *), void *arg)
{
if (!initialized)
badInit ("threadOnce");
if (!initialized) threadInit();
semMutexMustTake(onceMutex);
if (*id == 0) {
*id = -1;

View File

@@ -52,6 +52,7 @@ static semMutexId onceMutex;
static semMutexId listMutex;
static ELLLIST pthreadList;
static commonAttr *pcommonAttr = 0;
static int threadInitCalled = 0;
#define checkStatus(status,message) \
if((status)) {\
@@ -256,6 +257,7 @@ void threadInit(void)
{
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
int status = pthread_once(&once_control,once);
threadInitCalled = 1;
checkStatusQuit(status,"pthread_once","threadInit");
}
@@ -263,6 +265,7 @@ void threadInit(void)
void threadOnceOsd(threadOnceId *id, void (*func)(void *), void *arg)
{
if(!threadInitCalled) threadInit();
if(semMutexTake(onceMutex) != semTakeOK) {
fprintf(stderr,"threadOnceOsd semMutexTake failed.\n");
fprintf(stderr,"Did you call threadInit? Program exiting\n");
@@ -283,6 +286,7 @@ threadId threadCreate(const char *name,
threadInfo *pthreadInfo;
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");

View File

@@ -119,6 +119,7 @@ threadId threadCreate(const char *name,
THREADFUNC funptr,void *parm)
{
int tid;
if(threadOnceMutex==0) threadInit();
if(stackSize<100) {
errlogPrintf("threadCreate %s illegal stackSize %d\n",name,stackSize);
return(0);