Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017 Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017
<== Date ==> <== Thread ==>

Subject: EPICS with RTEMS posix osdThread.c implementation
From: "Heinz P. Junkes" <junkes@fhi-berlin.mpg.de>
To: core-talk@aps.anl.gov
Date: Mon, 17 Jul 2017 12:15:01 +0200
Right from the beginning I have problems with the posix implementation of RTEMS 4.12 when using the EPICS sources

in osi/os/posix. Especially in osdThread.c.

There is the function epicsThreadGetIdSelf. I have extended this function with a read to the threadInfoList to get the actual threadInfo

if the thread local threadInfo is not available (This happens in normal operation several times and I have no idea why).

I thought originally that has something to do with pthread_getspecific and I tried it with thread-local-variables "__thread" but with

the same result. Even the __thread variable sometimes had the value zero (it looks like it happens to the same places as with pthread_getspecific).

With my attempt to read the list, it is quite confident (createImplicite() gets never called) but I would gladly find the true error ;-)

Any Ideas what might go wrong?

Heinz



epicsShareFunc epicsThreadId epicsShareAPI epicsThreadGetIdSelf(void) {
    epicsThreadOSD *pthreadInfo;

    epicsThreadInit();
    pthreadInfo = (epicsThreadOSD *)pthread_getspecific(getpthreadInfo);
    if(pthreadInfo==NULL)
    {
        fprintf(stderr, "Houps ... will try to find it in the list ...\n");
        pthreadInfo = epicsThreadGetIdByTid(pthread_self());
        if(pthreadInfo==NULL)
{fprintf(stderr, " !!! Call createImplicit in epicsThreadGetIdSelf\n"); createImplicit();}
    }
    assert( pthreadInfo );
    return(pthreadInfo);
}

static epicsThreadOSD *epicsThreadGetIdByTid(pthread_t tid) {
    epicsThreadOSD *pthreadInfo;
    int status;

    assert(epicsThreadOnceCalled);
    status = mutexLock(&listLock);
    checkStatus(status,"pthread_mutex_lock epicsThreadGetIdByTid");
    if(status)
        return NULL;
    pthreadInfo=(epicsThreadOSD *)ellFirst(&pthreadList);
    while(pthreadInfo) {
      if(tid == pthreadInfo->tid) break;
        pthreadInfo=(epicsThreadOSD *)ellNext(&pthreadInfo->node);
    }
    status = pthread_mutex_unlock(&listLock);
    checkStatus(status,"pthread_mutex_unlock epicsThreadGetIdByTid");

    return(pthreadInfo);
}


Replies:
Re: EPICS with RTEMS posix osdThread.c implementation Michael Davidsaver

Navigate by Date:
Prev: Re: libCom posix/Linux Michael Davidsaver
Next: Re: EPICS with RTEMS posix osdThread.c implementation Michael Davidsaver
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017
Navigate by Thread:
Prev: Re: libCom posix/Linux Michael Davidsaver
Next: Re: EPICS with RTEMS posix osdThread.c implementation Michael Davidsaver
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017
ANJ, 17 Jul 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·