1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 <2007> 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 <2007> 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 |
<== Date ==> | <== Thread ==> |
---|
Subject: | EPICS thread problem on cygwin-x86 |
From: | "Mark Rivers" <[email protected]> |
To: | <[email protected]> |
Date: | Fri, 27 Apr 2007 13:01:12 -0500 |
Folks, I have found a problem with EPICS threads on cygwin-x86. The problem showed up when doing the command "asynReport" with the "details" argument=0 (default). The IOC crashes when this is done. It is a timing problem with the thread that asynReport creates. I have come up with a very simple test program to demonstrate the problem: /**************************************************************/ #include <epicsEvent.h> #include <epicsThread.h> #include <epicsExport.h> #include <iocsh.h> typedef struct myArgs { epicsEventId done; int delay; } myArgs; static void myThread(myArgs *pArgs) { if (pArgs->delay) epicsThreadSleep(.001); epicsEventSignal(pArgs->done); } static void threadTest(int delay) { myArgs args; epicsEventId done = epicsEventMustCreate(epicsEventEmpty); args.delay = delay; args.done = done; epicsThreadCreate("myThread", epicsThreadPriorityLow, epicsThreadGetStackSize(epicsThreadStackSmall), (EPICSTHREADFUNC)myThread, &args); epicsEventMustWait(done); epicsEventDestroy(done); } /* iocsh functions */ static const iocshArg threadArg0 = {"Delay", iocshArgInt}; static const iocshArg * const threadArgs[1] = {&threadArg0}; static const iocshFuncDef threadTestFuncDef= {"threadTest", 1, threadArgs}; static void threadTestCallFunc(const iocshArgBuf *args) { threadTest(args[0].ival); } static void threadTestRegister(void) { iocshRegister(&threadTestFuncDef, threadTestCallFunc); } epicsExportRegistrar(threadTestRegister); /**************************************************************/ The function threadTest() simply creates a thread, and then waits for it to complete with epicsEventMustWait(). If the delay argument is non-zero the thread sleeps for 0.001 second. It then signals the event and returns. On Linux this program works fine. However, on Cygwin it crashes if delay is 0, i.e. if it does not sleep for .001 second. $ ../../bin/cygwin-x86/threadTest.exe st.cmd #!../../bin/linux-x86/example ## You may have to change example to something else ## everywhere it appears in this file #< envPaths ## Register all support components dbLoadDatabase("../../dbd/threadTest.dbd",0,0) threadTest_registerRecordDeviceDriver(pdbbase) iocInit() Starting iocInit ######################################################################## #### ### EPICS IOC CORE built on Aug 25 2006 ### EPICS R3.14.8.2 $R3-14-8-2$ $2006/01/06 15:55:13$ ######################################################################## #### iocInit: All initialization complete epics> threadTest 1 epics> threadTest 0 pthread_create error Resource temporarily unavailable Segmentation fault (core dumped) This is a serious problem, since any thread that returns too quickly causes a crash on Cygwin. Can someone who knows about EPICS threads figure out why this is crashing, and how to fix it? Thanks, Mark
Attachment:
threadTest.c
Description: threadTest.c
Attachment:
threadTestInclude.dbd
Description: threadTestInclude.dbd
Attachment:
threadTestMain.cpp
Description: threadTestMain.cpp
Attachment:
Makefile
Description: Makefile