Experimental Physics and
| |||||||||||||||||
|
Which thread library is your machine using — is it the old LinuxThreads or NPTL? According to man pthreads you can use this shell command to find out: getconf GNU_LIBPTHREAD_VERSION I need to dig a bit into the pthread specification, but I'm sure I remember that _exit() is supposed to kill *everything* stone cold dead without ceremony. You are probably right. However since we don't actually call _exit() in this circumstance it doesn't really matter — th stuff about _exit() seems to have been a Red Herring I introduced by not looking at our implementation of epicsThreadExitMain() — sorry about that. We do have code in libCom/osi/os/posix that calls pthread_cancel() on all our threads, thus any call to epicsExit() will result in all our threads voluntarily shutting down. We had to introduce the epicsExit() and epicsAtExit() API because Windows runs atexit() routines after unloading all DLLs, even when the routines are found in said DLLs... What exactly does epicsThreadExitMain() do to try and close the top level thread without terminating the process? When I've had to do this in my own processes I've found it easiest to just created a semaphore and block on it. It calls pthread_exit(0). This appears to be legal since the Posix description of pthread_exit() includes the following wording: The process shall exit with an exit status of 0 after the last thread has been terminated. The behavior shall be as if the implementation called exit() with a zero argument at thread termination time. http://www.opengroup.org/onlinepubs/009695399/functions/pthread_exit.html However we don't actually rely on the above behaviour ourselves. Once epicsThreadExitMain() has been used the proper way to actually close an IOC down is for one of the remaining threads to call epicsExit(), which shuts down the other threads and calls exit(). HTH, - Andrew -- Talk is cheap. Show me the code. -- Linus Torvalds
| ||||||||||||||||
ANJ, 02 Sep 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |