diff --git a/src/libCom/osi/epicsThread.cpp b/src/libCom/osi/epicsThread.cpp index 2d26edde7..d1c965e5b 100644 --- a/src/libCom/osi/epicsThread.cpp +++ b/src/libCom/osi/epicsThread.cpp @@ -240,4 +240,13 @@ const char *epicsThread::getNameSelf () return epicsThreadGetNameSelf (); } +bool epicsThread::isShellContext () const +{ + return static_cast(epicsThreadIsShellContext(this->id)); +} + +void epicsThread::setShellContext(bool isShell) +{ + epicsThreadSetShellContext(this->id,static_cast(isShell)); +} diff --git a/src/libCom/osi/epicsThread.h b/src/libCom/osi/epicsThread.h index f5975a7c4..1301c117c 100644 --- a/src/libCom/osi/epicsThread.h +++ b/src/libCom/osi/epicsThread.h @@ -97,6 +97,10 @@ epicsShareFunc const char * epicsShareAPI epicsThreadGetNameSelf(void); epicsShareFunc void epicsShareAPI epicsThreadGetName( epicsThreadId id, char *name, size_t size); +epicsShareFunc int epicsShareAPI epicsThreadIsShellContext(epicsThreadId id); +epicsShareFunc void epicsShareAPI epicsThreadSetShellContext( + epicsThreadId id,int isShell); + epicsShareFunc void epicsShareAPI epicsThreadShowAll(unsigned int level); epicsShareFunc void epicsShareAPI epicsThreadShow( epicsThreadId id,unsigned int level); @@ -151,6 +155,8 @@ public: static void sleep (double seconds); /* static epicsThread & getSelf (); */ static const char * getNameSelf (); + bool isShellContext () const; + void setShellContext(bool isShell) ; class mustBeCalledByManagedThread {}; /* exception */ private: epicsThreadRunable & runable; diff --git a/src/libCom/osi/os/RTEMS/osdThread.c b/src/libCom/osi/os/RTEMS/osdThread.c index 7f0264f4a..da7b9ff0f 100644 --- a/src/libCom/osi/os/RTEMS/osdThread.c +++ b/src/libCom/osi/os/RTEMS/osdThread.c @@ -48,6 +48,7 @@ struct taskVar { void *parm; unsigned int threadVariableCapacity; void **threadVariables; + int isShell; }; static epicsMutexId taskVarMutex; static struct taskVar *taskVarHead; @@ -213,6 +214,7 @@ setThreadInfo (rtems_id tid, const char *name, EPICSTHREADFUNC funptr,void *parm v->parm = parm; v->threadVariableCapacity = 0; v->threadVariables = NULL; + v->isShell = 0; note = (rtems_unsigned32)v; rtems_task_set_note (tid, RTEMS_NOTEPAD_TASKVAR, note); taskVarLock (); @@ -452,6 +454,28 @@ epicsThreadId epicsThreadGetId (const char *name) return (epicsThreadId)tid; } +int epicsThreadIsShellContext (epicsThreadPrivateId id) +{ + unsigned int varIndex = (unsigned int)id; + rtems_unsigned32 note; + struct taskVar *v; + + rtems_task_get_note (RTEMS_SELF, RTEMS_NOTEPAD_TASKVAR, ¬e); + v = (struct taskVar *)note; + return v->isShell; +} + +void epicsThreadSetShellContext (epicsThreadPrivateId id,int isShell) +{ + unsigned int varIndex = (unsigned int)id; + rtems_unsigned32 note; + struct taskVar *v; + + rtems_task_get_note (RTEMS_SELF, RTEMS_NOTEPAD_TASKVAR, ¬e); + v = (struct taskVar *)note; + v->isShell = isShell; +} + /* * Ensure func() is run only once. */ diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index edea368b0..c6734b1ec 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -52,6 +52,7 @@ typedef struct win32ThreadParam { DWORD id; unsigned epicsPriority; char isSuspended; + int isShell; } win32ThreadParam; typedef struct epicsThreadPrivateOSD { @@ -844,6 +845,27 @@ epicsShareFunc void epicsShareAPI epicsThreadGetName ( } } +/* + * epicsThreadIsShellContext () + */ +epicsShareFunc int epicsShareAPI epicsThreadIsShellContext ( epicsThreadId id ) +{ + win32ThreadParam *pParm = ( win32ThreadParam * ) id; + + return pParm->isShell; +} + +/* + * epicsThreadSetShellContext () + */ +epicsShareFunc int epicsShareAPI epicsThreadSetShellContext ( + epicsThreadId id, int isShell) +{ + win32ThreadParam *pParm = ( win32ThreadParam * ) id; + + pParm->isShell = isShell; +} + /* * epics_GetThreadPriorityAsString () */ diff --git a/src/libCom/osi/os/posix/osdThread.c b/src/libCom/osi/os/posix/osdThread.c index 543249a80..c8c57b15e 100644 --- a/src/libCom/osi/os/posix/osdThread.c +++ b/src/libCom/osi/os/posix/osdThread.c @@ -55,6 +55,7 @@ typedef struct epicsThreadOSD { int isSuspended; unsigned int osiPriority; char *name; + int isShell; } epicsThreadOSD; static pthread_key_t getpthreadInfo; @@ -582,6 +583,18 @@ const char *epicsThreadGetNameSelf() return(pthreadInfo->name); } +int epicsThreadIsShellContext(epicsThreadId pthreadInfo) { + assert(epicsThreadOnceCalled); + assert(pthreadInfo); + return pthreadInfo->isShell; +} + +void epicsThreadSetShellContext(epicsThreadId pthreadInfo,int isShell) { + assert(epicsThreadOnceCalled); + assert(pthreadInfo); + pthreadInfo->isShell = isShell; +} + void epicsThreadGetName(epicsThreadId pthreadInfo, char *name, size_t size) { assert(epicsThreadOnceCalled); diff --git a/src/libCom/osi/os/vxWorks/osdThread.c b/src/libCom/osi/os/vxWorks/osdThread.c index 583077269..3f5d734d7 100644 --- a/src/libCom/osi/os/vxWorks/osdThread.c +++ b/src/libCom/osi/os/vxWorks/osdThread.c @@ -40,6 +40,9 @@ static const unsigned stackSizeTable[epicsThreadStackBig+1] = {4000*ARCH_STACK_FACTOR, 6000*ARCH_STACK_FACTOR, 11000*ARCH_STACK_FACTOR}; +/*tasVar for isShell*/ +int isShell; + /* definitions for implementation of epicsThreadPrivate */ static void **papTSD = 0; static int nepicsThreadPrivate = 0; @@ -125,6 +128,7 @@ static void createFunction(EPICSTHREADFUNC func, void *parm) (*func)(parm); free(papTSD); taskVarDelete(tid,(int *)&papTSD); + taskVarDelete(tid,&isShell); } epicsThreadId epicsThreadCreate(const char *name, @@ -145,6 +149,8 @@ epicsThreadId epicsThreadCreate(const char *name, errlogPrintf("epicsThreadCreate taskSpawn failure for %s\n",name); return(0); } + taskVarAdd(tid,&isShell); + taskVarSet(tid,&isShell,0); return((epicsThreadId)tid); } @@ -270,6 +276,16 @@ void epicsThreadGetName (epicsThreadId id, char *name, size_t size) name[size-1] = '\0'; } +int epicsThreadIsShellContext(epicsThreadId id) +{ + return isShell; +} + +void epicsThreadSetShellContext(epicsThreadId id,int yesNo) +{ + isShell = yesNo; +} + void epicsThreadShowAll(unsigned int level) { taskShow(0,2);