epicsThreadIsOkToBlock epicsThreadSetOkToBlock only for calling thread
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include "epicsStdio.h"
|
||||
#include "ellLib.h"
|
||||
#include "asLib.h"
|
||||
#include "asDbLib.h"
|
||||
#include "asCa.h"
|
||||
#define epicsExportSharedSymbols
|
||||
@@ -114,6 +116,40 @@ static void ascarCallFunc(const iocshArgBuf *args)
|
||||
ascar(args[0].ival);
|
||||
}
|
||||
|
||||
/* asDumpUag */
|
||||
static const iocshArg asDumpUagArg0 = { "uagname",iocshArgString};
|
||||
static const iocshArg * const asDumpUagArgs[] = {&asDumpUagArg0};
|
||||
static const iocshFuncDef asDumpUagFuncDef = {"asDumpUag",1,asDumpUagArgs};
|
||||
static void asDumpUagCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
asDumpUag(args[0].sval);
|
||||
}
|
||||
|
||||
/* asDumpHag */
|
||||
static const iocshArg asDumpHagArg0 = { "hagname",iocshArgString};
|
||||
static const iocshArg * const asDumpHagArgs[] = {&asDumpHagArg0};
|
||||
static const iocshFuncDef asDumpHagFuncDef = {"asDumpHag",1,asDumpHagArgs};
|
||||
static void asDumpHagCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
asDumpHag(args[0].sval);
|
||||
}
|
||||
|
||||
/* asDumpRules */
|
||||
static const iocshArg asDumpRulesArg0 = { "asgname",iocshArgString};
|
||||
static const iocshArg * const asDumpRulesArgs[] = {&asDumpRulesArg0};
|
||||
static const iocshFuncDef asDumpRulesFuncDef = {"asDumpRules",1,asDumpRulesArgs};
|
||||
static void asDumpRulesCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
asDumpRules(args[0].sval);
|
||||
}
|
||||
|
||||
/* asDumpHash */
|
||||
static const iocshFuncDef asDumpHashFuncDef = {"asDumpHash",0,0};
|
||||
static void asDumpHashCallFunc(const iocshArgBuf *args)
|
||||
{
|
||||
asDumpHash();
|
||||
}
|
||||
|
||||
void epicsShareAPI asTestRegister(void)
|
||||
{
|
||||
iocshRegister(&asSetFilenameFuncDef,asSetFilenameCallFunc);
|
||||
@@ -126,4 +162,8 @@ void epicsShareAPI asTestRegister(void)
|
||||
iocshRegister(&aspmemFuncDef,aspmemCallFunc);
|
||||
iocshRegister(&astacFuncDef,astacCallFunc);
|
||||
iocshRegister(&ascarFuncDef,ascarCallFunc);
|
||||
iocshRegister(&asDumpUagFuncDef,asDumpUagCallFunc);
|
||||
iocshRegister(&asDumpHagFuncDef,asDumpHagCallFunc);
|
||||
iocshRegister(&asDumpRulesFuncDef,asDumpRulesCallFunc);
|
||||
iocshRegister(&asDumpHashFuncDef,asDumpHashCallFunc);
|
||||
}
|
||||
|
||||
@@ -106,10 +106,8 @@ static void dbiorCallFunc(const iocshArgBuf *args)
|
||||
{ dbior(args[0].sval,args[1].ival);}
|
||||
|
||||
/* dbhcr */
|
||||
static const iocshArg dbhcrArg0 = { "filename",iocshArgString};
|
||||
static const iocshArg * const dbhcrArgs[1] = {&dbhcrArg0};
|
||||
static const iocshFuncDef dbhcrFuncDef = {"dbhcr",1,dbhcrArgs};
|
||||
static void dbhcrCallFunc(const iocshArgBuf *args) { dbhcr(args[0].sval);}
|
||||
static const iocshFuncDef dbhcrFuncDef = {"dbhcr",0,0};
|
||||
static void dbhcrCallFunc(const iocshArgBuf *args) { dbhcr();}
|
||||
|
||||
/* gft */
|
||||
static const iocshArg gftArg0 = { "record name",iocshArgString};
|
||||
|
||||
@@ -418,8 +418,8 @@ iocsh (const char *pathname)
|
||||
* Read commands till EOF or exit
|
||||
*/
|
||||
argc = 0;
|
||||
wasOkToBlock = epicsThreadIsOkToBlock(epicsThreadGetIdSelf());
|
||||
epicsThreadSetOkToBlock(epicsThreadGetIdSelf(), 1);
|
||||
wasOkToBlock = epicsThreadIsOkToBlock();
|
||||
epicsThreadSetOkToBlock(1);
|
||||
for (;;) {
|
||||
|
||||
/*
|
||||
@@ -730,7 +730,7 @@ iocsh (const char *pathname)
|
||||
free (argBuf);
|
||||
errlogFlush();
|
||||
epicsReadlineEnd(readlineContext);
|
||||
epicsThreadSetOkToBlock(epicsThreadGetIdSelf(), wasOkToBlock);
|
||||
epicsThreadSetOkToBlock( wasOkToBlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ epicsShareFunc int errlogVprintf(
|
||||
{
|
||||
int nchar;
|
||||
char *pbuffer;
|
||||
int isOkToBlock = epicsThreadIsOkToBlock(epicsThreadGetIdSelf());
|
||||
int isOkToBlock = epicsThreadIsOkToBlock();
|
||||
|
||||
if(epicsInterruptIsInterruptContext()) {
|
||||
epicsInterruptContextMessage
|
||||
@@ -211,7 +211,7 @@ epicsShareFunc int errlogSevVprintf(
|
||||
char *pnext;
|
||||
int nchar;
|
||||
int totalChar=0;
|
||||
int isOkToBlock = epicsThreadIsOkToBlock(epicsThreadGetIdSelf());
|
||||
int isOkToBlock = epicsThreadIsOkToBlock();
|
||||
char *pmessage;
|
||||
|
||||
if(pvtData.sevToLog>severity) return(0);
|
||||
@@ -308,7 +308,7 @@ epicsShareFunc void errPrintf(long status, const char *pFileName,
|
||||
char *pnext;
|
||||
int nchar;
|
||||
int totalChar=0;
|
||||
int isOkToBlock = epicsThreadIsOkToBlock(epicsThreadGetIdSelf());
|
||||
int isOkToBlock = epicsThreadIsOkToBlock();
|
||||
char *pmessage;
|
||||
|
||||
if(epicsInterruptIsInterruptContext()) {
|
||||
|
||||
@@ -240,13 +240,13 @@ const char *epicsThread::getNameSelf ()
|
||||
return epicsThreadGetNameSelf ();
|
||||
}
|
||||
|
||||
bool epicsThread::isOkToBlock () const
|
||||
bool epicsThread::isOkToBlock ()
|
||||
{
|
||||
return static_cast<int>(epicsThreadIsOkToBlock(this->id));
|
||||
return static_cast<int>(epicsThreadIsOkToBlock());
|
||||
}
|
||||
|
||||
void epicsThread::setOkToBlock(bool isOkToBlock)
|
||||
{
|
||||
epicsThreadSetOkToBlock(this->id,static_cast<int>(isOkToBlock));
|
||||
epicsThreadSetOkToBlock(static_cast<int>(isOkToBlock));
|
||||
}
|
||||
|
||||
|
||||
@@ -97,9 +97,8 @@ epicsShareFunc const char * epicsShareAPI epicsThreadGetNameSelf(void);
|
||||
epicsShareFunc void epicsShareAPI epicsThreadGetName(
|
||||
epicsThreadId id, char *name, size_t size);
|
||||
|
||||
epicsShareFunc int epicsShareAPI epicsThreadIsOkToBlock(epicsThreadId id);
|
||||
epicsShareFunc void epicsShareAPI epicsThreadSetOkToBlock(
|
||||
epicsThreadId id,int isOkToBlock);
|
||||
epicsShareFunc int epicsShareAPI epicsThreadIsOkToBlock(void);
|
||||
epicsShareFunc void epicsShareAPI epicsThreadSetOkToBlock(int isOkToBlock);
|
||||
|
||||
epicsShareFunc void epicsShareAPI epicsThreadShowAll(unsigned int level);
|
||||
epicsShareFunc void epicsShareAPI epicsThreadShow(
|
||||
@@ -155,8 +154,8 @@ public:
|
||||
static void sleep (double seconds);
|
||||
/* static epicsThread & getSelf (); */
|
||||
static const char * getNameSelf ();
|
||||
bool isOkToBlock () const;
|
||||
void setOkToBlock(bool isOkToBlock) ;
|
||||
static bool isOkToBlock () ;
|
||||
static void setOkToBlock(bool isOkToBlock) ;
|
||||
class mustBeCalledByManagedThread {}; /* exception */
|
||||
private:
|
||||
epicsThreadRunable & runable;
|
||||
|
||||
@@ -454,9 +454,9 @@ epicsThreadId epicsThreadGetId (const char *name)
|
||||
return (epicsThreadId)tid;
|
||||
}
|
||||
|
||||
int epicsThreadIsOkToBlock (epicsThreadId id)
|
||||
int epicsThreadIsOkToBlock (void)
|
||||
{
|
||||
rtems_id tid = (rtems_id)id;
|
||||
rtems_id tid = (rtems_id)epicsThreadGetIdSelf();
|
||||
rtems_status_code sc;
|
||||
rtems_unsigned32 note;
|
||||
struct taskVar *v;
|
||||
@@ -475,9 +475,9 @@ int epicsThreadIsOkToBlock (epicsThreadId id)
|
||||
return okToBlock;
|
||||
}
|
||||
|
||||
void epicsThreadSetOkToBlock (epicsThreadId id,int isOkToBlock)
|
||||
void epicsThreadSetOkToBlock (int isOkToBlock)
|
||||
{
|
||||
rtems_id tid = (rtems_id)id;
|
||||
rtems_id tid = (rtems_id)epicsThreadGetIdSelf();
|
||||
rtems_status_code sc;
|
||||
rtems_unsigned32 note;
|
||||
struct taskVar *v;
|
||||
|
||||
@@ -848,8 +848,9 @@ epicsShareFunc void epicsShareAPI epicsThreadGetName (
|
||||
/*
|
||||
* epicsThreadIsOkToBlock ()
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI epicsThreadIsOkToBlock ( epicsThreadId id )
|
||||
epicsShareFunc int epicsShareAPI epicsThreadIsOkToBlock (void);
|
||||
{
|
||||
epicsThreadId id = epicsThreadGetIdSelf();
|
||||
win32ThreadParam *pParm = ( win32ThreadParam * ) id;
|
||||
|
||||
return pParm->isOkToBlock;
|
||||
@@ -858,9 +859,9 @@ epicsShareFunc int epicsShareAPI epicsThreadIsOkToBlock ( epicsThreadId id )
|
||||
/*
|
||||
* epicsThreadSetOkToBlock ()
|
||||
*/
|
||||
epicsShareFunc int epicsShareAPI epicsThreadSetOkToBlock (
|
||||
epicsThreadId id, int isOkToBlock)
|
||||
epicsShareFunc int epicsShareAPI epicsThreadSetOkToBlock ( int isOkToBlock)
|
||||
{
|
||||
epicsThreadId id = epicsThreadGetIdSelf();
|
||||
win32ThreadParam *pParm = ( win32ThreadParam * ) id;
|
||||
|
||||
pParm->isOkToBlock = isOkToBlock;
|
||||
|
||||
@@ -583,15 +583,14 @@ const char *epicsThreadGetNameSelf()
|
||||
return(pthreadInfo->name);
|
||||
}
|
||||
|
||||
int epicsThreadIsOkToBlock(epicsThreadId pthreadInfo) {
|
||||
assert(epicsThreadOnceCalled);
|
||||
assert(pthreadInfo);
|
||||
int epicsThreadIsOkToBlock(void)
|
||||
{
|
||||
epicsThreadId pthreadInfo = epicsThreadGetIdSelf();
|
||||
return pthreadInfo->isOkToBlock;
|
||||
}
|
||||
|
||||
void epicsThreadSetOkToBlock(epicsThreadId pthreadInfo,int isOkToBlock) {
|
||||
assert(epicsThreadOnceCalled);
|
||||
assert(pthreadInfo);
|
||||
void epicsThreadSetOkToBlock(int isOkToBlock) {
|
||||
epicsThreadId pthreadInfo = epicsThreadGetIdSelf();
|
||||
pthreadInfo->isOkToBlock = isOkToBlock;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,14 +276,14 @@ void epicsThreadGetName (epicsThreadId id, char *name, size_t size)
|
||||
name[size-1] = '\0';
|
||||
}
|
||||
|
||||
int epicsThreadIsOkToBlock(epicsThreadId id)
|
||||
int epicsThreadIsOkToBlock(void)
|
||||
{
|
||||
return isOkToBlock;
|
||||
return taskVarGet(taskIdSelf(),&isOkToBlock);
|
||||
}
|
||||
|
||||
void epicsThreadSetOkToBlock(epicsThreadId id,int yesNo)
|
||||
void epicsThreadSetOkToBlock(int yesNo)
|
||||
{
|
||||
isOkToBlock = yesNo;
|
||||
taskVarSet(taskIdSelf(),&isOkToBlock,yesNo);
|
||||
}
|
||||
|
||||
void epicsThreadShowAll(unsigned int level)
|
||||
|
||||
@@ -30,14 +30,13 @@ 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);
|
||||
epicsThreadSetOkToBlock(pinfo->isOkToBlock);
|
||||
epicsThreadSleep(1.0);
|
||||
isOkToBlock = epicsThreadIsOkToBlock(idSelf);
|
||||
isOkToBlock = epicsThreadIsOkToBlock();
|
||||
printf("thread %s epicsThreadIsOkToBlock %d\n",
|
||||
epicsThreadGetNameSelf(),isOkToBlock);
|
||||
epicsThreadSleep(.1);
|
||||
|
||||
@@ -79,8 +79,7 @@ int epicsShareAPI iocInit()
|
||||
errlogPrintf("iocInit can only be called once\n");
|
||||
return(-1);
|
||||
}
|
||||
if(!epicsThreadIsOkToBlock(epicsThreadGetIdSelf()))
|
||||
epicsThreadSetOkToBlock(epicsThreadGetIdSelf(),1);
|
||||
if(!epicsThreadIsOkToBlock()) epicsThreadSetOkToBlock(1);
|
||||
errlogPrintf("Starting iocInit\n");
|
||||
if (!pdbbase) {
|
||||
errlogPrintf("iocInit aborting because No database\n");
|
||||
|
||||
Reference in New Issue
Block a user