ShellContext=>OkToBlock
This commit is contained in:
@@ -128,7 +128,7 @@ epicsShareFunc int errlogVprintf(
|
||||
{
|
||||
int nchar;
|
||||
char *pbuffer;
|
||||
int isShell = epicsThreadIsShellContext(epicsThreadGetIdSelf());
|
||||
int isOkToBlock = epicsThreadIsOkToBlock(epicsThreadGetIdSelf());
|
||||
|
||||
if(epicsInterruptIsInterruptContext()) {
|
||||
epicsInterruptContextMessage
|
||||
@@ -136,11 +136,11 @@ epicsShareFunc int errlogVprintf(
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
pbuffer = msgbufGetFree(!isShell);
|
||||
pbuffer = msgbufGetFree(!isOkToBlock);
|
||||
if(!pbuffer) return(0);
|
||||
nchar = tvsnPrint(pbuffer,MAX_MESSAGE_SIZE,pFormat?pFormat:"",pvar);
|
||||
msgbufSetSize(nchar);
|
||||
if(isShell) printf("%s",pbuffer);
|
||||
if(isOkToBlock) printf("%s",pbuffer);
|
||||
return nchar;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ epicsShareFunc int errlogSevVprintf(
|
||||
char *pnext;
|
||||
int nchar;
|
||||
int totalChar=0;
|
||||
int isShell = epicsThreadIsShellContext(epicsThreadGetIdSelf());
|
||||
int isOkToBlock = epicsThreadIsOkToBlock(epicsThreadGetIdSelf());
|
||||
char *pmessage;
|
||||
|
||||
if(pvtData.sevToLog>severity) return(0);
|
||||
@@ -221,7 +221,7 @@ epicsShareFunc int errlogSevVprintf(
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
pnext = msgbufGetFree(!isShell);
|
||||
pnext = msgbufGetFree(!isOkToBlock);
|
||||
pmessage = pnext;
|
||||
if(!pnext) return(0);
|
||||
nchar = sprintf(pnext,"sevr=%s ",errlogGetSevEnumString(severity));
|
||||
@@ -233,7 +233,7 @@ epicsShareFunc int errlogSevVprintf(
|
||||
totalChar++;
|
||||
}
|
||||
msgbufSetSize(totalChar);
|
||||
if(isShell) printf("%s",pmessage);
|
||||
if(isOkToBlock) printf("%s",pmessage);
|
||||
return(nchar);
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ epicsShareFunc void errPrintf(long status, const char *pFileName,
|
||||
char *pnext;
|
||||
int nchar;
|
||||
int totalChar=0;
|
||||
int isShell = epicsThreadIsShellContext(epicsThreadGetIdSelf());
|
||||
int isOkToBlock = epicsThreadIsOkToBlock(epicsThreadGetIdSelf());
|
||||
char *pmessage;
|
||||
|
||||
if(epicsInterruptIsInterruptContext()) {
|
||||
@@ -316,7 +316,7 @@ epicsShareFunc void errPrintf(long status, const char *pFileName,
|
||||
return;
|
||||
}
|
||||
errlogInit(0);
|
||||
pnext = msgbufGetFree(!isShell);
|
||||
pnext = msgbufGetFree(!isOkToBlock);
|
||||
pmessage = pnext;
|
||||
if(!pnext) return;
|
||||
if(pFileName){
|
||||
@@ -342,7 +342,7 @@ epicsShareFunc void errPrintf(long status, const char *pFileName,
|
||||
strcpy(pnext,"\n");
|
||||
totalChar++ ; /*include the \n */
|
||||
msgbufSetSize(totalChar);
|
||||
if(isShell) printf("%s",pmessage);
|
||||
if(isOkToBlock) printf("%s",pmessage);
|
||||
}
|
||||
|
||||
static void errlogInitPvt(void *arg)
|
||||
|
||||
@@ -240,13 +240,13 @@ const char *epicsThread::getNameSelf ()
|
||||
return epicsThreadGetNameSelf ();
|
||||
}
|
||||
|
||||
bool epicsThread::isShellContext () const
|
||||
bool epicsThread::isOkToBlock () const
|
||||
{
|
||||
return static_cast<int>(epicsThreadIsShellContext(this->id));
|
||||
return static_cast<int>(epicsThreadIsOkToBlock(this->id));
|
||||
}
|
||||
|
||||
void epicsThread::setShellContext(bool isShell)
|
||||
void epicsThread::setOkToBlock(bool isOkToBlock)
|
||||
{
|
||||
epicsThreadSetShellContext(this->id,static_cast<int>(isShell));
|
||||
epicsThreadSetOkToBlock(this->id,static_cast<int>(isOkToBlock));
|
||||
}
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ 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 int epicsShareAPI epicsThreadIsOkToBlock(epicsThreadId id);
|
||||
epicsShareFunc void epicsShareAPI epicsThreadSetOkToBlock(
|
||||
epicsThreadId id,int isOkToBlock);
|
||||
|
||||
epicsShareFunc void epicsShareAPI epicsThreadShowAll(unsigned int level);
|
||||
epicsShareFunc void epicsShareAPI epicsThreadShow(
|
||||
@@ -155,8 +155,8 @@ public:
|
||||
static void sleep (double seconds);
|
||||
/* static epicsThread & getSelf (); */
|
||||
static const char * getNameSelf ();
|
||||
bool isShellContext () const;
|
||||
void setShellContext(bool isShell) ;
|
||||
bool isOkToBlock () const;
|
||||
void setOkToBlock(bool isOkToBlock) ;
|
||||
class mustBeCalledByManagedThread {}; /* exception */
|
||||
private:
|
||||
epicsThreadRunable & runable;
|
||||
|
||||
@@ -48,7 +48,7 @@ struct taskVar {
|
||||
void *parm;
|
||||
unsigned int threadVariableCapacity;
|
||||
void **threadVariables;
|
||||
int isShell;
|
||||
int isOkToBlock;
|
||||
};
|
||||
static epicsMutexId taskVarMutex;
|
||||
static struct taskVar *taskVarHead;
|
||||
@@ -214,7 +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;
|
||||
v->isOkToBlock = 0;
|
||||
note = (rtems_unsigned32)v;
|
||||
rtems_task_set_note (tid, RTEMS_NOTEPAD_TASKVAR, note);
|
||||
taskVarLock ();
|
||||
@@ -454,7 +454,7 @@ epicsThreadId epicsThreadGetId (const char *name)
|
||||
return (epicsThreadId)tid;
|
||||
}
|
||||
|
||||
int epicsThreadIsShellContext (epicsThreadPrivateId id)
|
||||
int epicsThreadIsOkToBlock (epicsThreadPrivateId id)
|
||||
{
|
||||
unsigned int varIndex = (unsigned int)id;
|
||||
rtems_unsigned32 note;
|
||||
@@ -462,10 +462,10 @@ int epicsThreadIsShellContext (epicsThreadPrivateId id)
|
||||
|
||||
rtems_task_get_note (RTEMS_SELF, RTEMS_NOTEPAD_TASKVAR, ¬e);
|
||||
v = (struct taskVar *)note;
|
||||
return v->isShell;
|
||||
return v->isOkToBlock;
|
||||
}
|
||||
|
||||
void epicsThreadSetShellContext (epicsThreadPrivateId id,int isShell)
|
||||
void epicsThreadSetOkToBlock (epicsThreadPrivateId id,int isOkToBlock)
|
||||
{
|
||||
unsigned int varIndex = (unsigned int)id;
|
||||
rtems_unsigned32 note;
|
||||
@@ -473,7 +473,7 @@ void epicsThreadSetShellContext (epicsThreadPrivateId id,int isShell)
|
||||
|
||||
rtems_task_get_note (RTEMS_SELF, RTEMS_NOTEPAD_TASKVAR, ¬e);
|
||||
v = (struct taskVar *)note;
|
||||
v->isShell = isShell;
|
||||
v->isOkToBlock = isOkToBlock;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -52,7 +52,7 @@ typedef struct win32ThreadParam {
|
||||
DWORD id;
|
||||
unsigned epicsPriority;
|
||||
char isSuspended;
|
||||
int isShell;
|
||||
int isOkToBlock;
|
||||
} win32ThreadParam;
|
||||
|
||||
typedef struct epicsThreadPrivateOSD {
|
||||
@@ -846,24 +846,24 @@ epicsShareFunc void epicsShareAPI epicsThreadGetName (
|
||||
}
|
||||
|
||||
/*
|
||||
* epicsThreadIsShellContext ()
|
||||
* epicsThreadIsOkToBlock ()
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI epicsThreadIsShellContext ( epicsThreadId id )
|
||||
epicsShareFunc int epicsShareAPI epicsThreadIsOkToBlock ( epicsThreadId id )
|
||||
{
|
||||
win32ThreadParam *pParm = ( win32ThreadParam * ) id;
|
||||
|
||||
return pParm->isShell;
|
||||
return pParm->isOkToBlock;
|
||||
}
|
||||
|
||||
/*
|
||||
* epicsThreadSetShellContext ()
|
||||
* epicsThreadSetOkToBlock ()
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI epicsThreadSetShellContext (
|
||||
epicsThreadId id, int isShell)
|
||||
epicsShareFunc int epicsShareAPI epicsThreadSetOkToBlock (
|
||||
epicsThreadId id, int isOkToBlock)
|
||||
{
|
||||
win32ThreadParam *pParm = ( win32ThreadParam * ) id;
|
||||
|
||||
pParm->isShell = isShell;
|
||||
pParm->isOkToBlock = isOkToBlock;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -55,7 +55,7 @@ typedef struct epicsThreadOSD {
|
||||
int isSuspended;
|
||||
unsigned int osiPriority;
|
||||
char *name;
|
||||
int isShell;
|
||||
int isOkToBlock;
|
||||
} epicsThreadOSD;
|
||||
|
||||
static pthread_key_t getpthreadInfo;
|
||||
@@ -583,16 +583,16 @@ const char *epicsThreadGetNameSelf()
|
||||
return(pthreadInfo->name);
|
||||
}
|
||||
|
||||
int epicsThreadIsShellContext(epicsThreadId pthreadInfo) {
|
||||
int epicsThreadIsOkToBlock(epicsThreadId pthreadInfo) {
|
||||
assert(epicsThreadOnceCalled);
|
||||
assert(pthreadInfo);
|
||||
return pthreadInfo->isShell;
|
||||
return pthreadInfo->isOkToBlock;
|
||||
}
|
||||
|
||||
void epicsThreadSetShellContext(epicsThreadId pthreadInfo,int isShell) {
|
||||
void epicsThreadSetOkToBlock(epicsThreadId pthreadInfo,int isOkToBlock) {
|
||||
assert(epicsThreadOnceCalled);
|
||||
assert(pthreadInfo);
|
||||
pthreadInfo->isShell = isShell;
|
||||
pthreadInfo->isOkToBlock = isOkToBlock;
|
||||
}
|
||||
|
||||
void epicsThreadGetName(epicsThreadId pthreadInfo, char *name, size_t size)
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
static const unsigned stackSizeTable[epicsThreadStackBig+1] =
|
||||
{4000*ARCH_STACK_FACTOR, 6000*ARCH_STACK_FACTOR, 11000*ARCH_STACK_FACTOR};
|
||||
|
||||
/*tasVar for isShell*/
|
||||
int isShell;
|
||||
/*tasVar for isOkToBlock*/
|
||||
int isOkToBlock;
|
||||
|
||||
/* definitions for implementation of epicsThreadPrivate */
|
||||
static void **papTSD = 0;
|
||||
@@ -128,7 +128,7 @@ static void createFunction(EPICSTHREADFUNC func, void *parm)
|
||||
(*func)(parm);
|
||||
free(papTSD);
|
||||
taskVarDelete(tid,(int *)&papTSD);
|
||||
taskVarDelete(tid,&isShell);
|
||||
taskVarDelete(tid,&isOkToBlock);
|
||||
}
|
||||
|
||||
epicsThreadId epicsThreadCreate(const char *name,
|
||||
@@ -149,8 +149,8 @@ epicsThreadId epicsThreadCreate(const char *name,
|
||||
errlogPrintf("epicsThreadCreate taskSpawn failure for %s\n",name);
|
||||
return(0);
|
||||
}
|
||||
taskVarAdd(tid,&isShell);
|
||||
taskVarSet(tid,&isShell,0);
|
||||
taskVarAdd(tid,&isOkToBlock);
|
||||
taskVarSet(tid,&isOkToBlock,0);
|
||||
return((epicsThreadId)tid);
|
||||
}
|
||||
|
||||
@@ -276,14 +276,14 @@ void epicsThreadGetName (epicsThreadId id, char *name, size_t size)
|
||||
name[size-1] = '\0';
|
||||
}
|
||||
|
||||
int epicsThreadIsShellContext(epicsThreadId id)
|
||||
int epicsThreadIsOkToBlock(epicsThreadId id)
|
||||
{
|
||||
return isShell;
|
||||
return isOkToBlock;
|
||||
}
|
||||
|
||||
void epicsThreadSetShellContext(epicsThreadId id,int yesNo)
|
||||
void epicsThreadSetOkToBlock(epicsThreadId id,int yesNo)
|
||||
{
|
||||
isShell = yesNo;
|
||||
isOkToBlock = yesNo;
|
||||
}
|
||||
|
||||
void epicsThreadShowAll(unsigned int level)
|
||||
|
||||
@@ -46,6 +46,11 @@ epicsThreadPrivateTestHost_SRCS += epicsThreadPrivateTestMain.cpp epicsThreadPri
|
||||
PROD_HOST += epicsThreadPrivateTestHost
|
||||
OBJS_IOC_vxWorks += epicsThreadPrivateTest
|
||||
|
||||
epicsOkToBlockTestHost_SRCS += epicsOkToBlockTestMain.cpp epicsOkToBlockTest.cpp
|
||||
PROD_HOST += epicsOkToBlockTestHost
|
||||
OBJS_IOC_vxWorks += epicsOkToBlockTest
|
||||
|
||||
|
||||
epicsTimerTestHost_SRCS += epicsTimerTestMain.cpp epicsTimerTest.cpp
|
||||
PROD_HOST += epicsTimerTestHost
|
||||
OBJS_IOC_vxWorks += epicsTimerTest
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
/* epicsOkToBlockTest.cpp */
|
||||
|
||||
/* Author: Marty Kraimer Date: 09JUL2004*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "epicsThread.h"
|
||||
|
||||
|
||||
typedef struct info {
|
||||
int isOkToBlock;
|
||||
}info;
|
||||
|
||||
extern "C" {
|
||||
|
||||
static void thread(void *arg)
|
||||
{
|
||||
info *pinfo = (info *)arg;
|
||||
epicsThreadId idSelf = epicsThreadGetIdSelf();
|
||||
int isOkToBlock;
|
||||
|
||||
printf("thread %s isOkToBlock %d\n",
|
||||
epicsThreadGetNameSelf(),pinfo->isOkToBlock);
|
||||
epicsThreadSetOkToBlock(idSelf,pinfo->isOkToBlock);
|
||||
epicsThreadSleep(1.0);
|
||||
isOkToBlock = epicsThreadIsOkToBlock(idSelf);
|
||||
printf("thread %s epicsThreadIsOkToBlock %d\n",
|
||||
epicsThreadGetNameSelf(),isOkToBlock);
|
||||
epicsThreadSleep(.1);
|
||||
free(pinfo);
|
||||
}
|
||||
void epicsOkToBlockTest(void)
|
||||
{
|
||||
unsigned int stackSize;
|
||||
info *pinfo;
|
||||
|
||||
stackSize = epicsThreadGetStackSize(epicsThreadStackSmall);
|
||||
pinfo = (info *)calloc(1,sizeof(info));
|
||||
pinfo->isOkToBlock = 0;
|
||||
epicsThreadCreate("threadA",50,stackSize,thread,pinfo);
|
||||
pinfo = (info *)calloc(1,sizeof(info));
|
||||
pinfo->isOkToBlock = 1;
|
||||
epicsThreadCreate("threadB",50,stackSize,thread,pinfo);
|
||||
epicsThreadSleep(2.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
/* epicsOkToBlockTestMain.cpp */
|
||||
|
||||
/* Author: Marty Kraimer Date: 26JAN2000 */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
extern "C" void epicsOkToBlockTest(void);
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
epicsOkToBlockTest();
|
||||
printf("main terminating\n");
|
||||
return(0);
|
||||
}
|
||||
Reference in New Issue
Block a user