EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: EPICS with RTEMS posix osdThread.c implementation
From: Michael Davidsaver <[email protected]>
To: "Heinz P. Junkes" <[email protected]>, [email protected]
Date: Mon, 17 Jul 2017 13:40:52 +0200
I'm not sure I understand what code you're referring to.

https://git.launchpad.net/~epics-core/epics-base/+git/add-rtems-4.12-api/tree/src/libCom/osi/os/posix/osdThread.c

has

> __thread epicsThreadOSD *tls_pthreadInfo;

So the initial values of this variable are zero.  Same for pthread TLS
variables.

1. For threads created with epicsThreadCreate() this variable is set
before the thread function is called.  So tls_pthreadInfo should never
be seen as non-zero.

2. For the "main" thread, tls_pthreadInfo is set during
epicsThreadInit(), so 'tls_pthreadInfo==NULL' will only be seen before
this has been called().

3. Other "non-epics" threads will see 'tls_pthreadInfo==NULL' until
createImplicit() is called.


On which line, and in which case(s), do you see unexpected
'tls_pthreadInfo==NULL'




On 07/17/2017 12:15 PM, Heinz P. Junkes wrote:
> 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);
> }
> 


References:
EPICS with RTEMS posix osdThread.c implementation Heinz P. Junkes

Navigate by Date:
Prev: EPICS with RTEMS posix osdThread.c implementation Heinz P. Junkes
Next: Re: clone R3.16 error Andrew Johnson
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: EPICS with RTEMS posix osdThread.c implementation Heinz P. Junkes
Next: Re: clone R3.16 error Andrew Johnson
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
ANJ, 21 Dec 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·