changes for osiThread=>epicsThread
This commit is contained in:
+10
-10
@@ -19,7 +19,7 @@ of this distribution.
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "osiThread.h"
|
||||
#include "epicsThread.h"
|
||||
#include "osiInterrupt.h"
|
||||
#include "osiTimer.h"
|
||||
#include "epicsRingPointer.h"
|
||||
@@ -42,7 +42,7 @@ of this distribution.
|
||||
int callbackQueueSize = 2000;
|
||||
static epicsEventId callbackSem[NUM_CALLBACK_PRIORITIES];
|
||||
static epicsRingPointerId callbackQ[NUM_CALLBACK_PRIORITIES];
|
||||
static threadId callbackTaskId[NUM_CALLBACK_PRIORITIES];
|
||||
static epicsThreadId callbackTaskId[NUM_CALLBACK_PRIORITIES];
|
||||
static int ringOverflow[NUM_CALLBACK_PRIORITIES];
|
||||
static void callbackInitPvt(void *);
|
||||
volatile int callbackRestart=FALSE;
|
||||
@@ -74,7 +74,7 @@ static void callbackInitPvt(void *arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
timerQueue = osiTimerQueueCreate(threadPriorityScanHigh);
|
||||
timerQueue = osiTimerQueueCreate(epicsThreadPriorityScanHigh);
|
||||
for(i=0; i<NUM_CALLBACK_PRIORITIES; i++) {
|
||||
start(i);
|
||||
}
|
||||
@@ -82,9 +82,9 @@ static void callbackInitPvt(void *arg)
|
||||
|
||||
void epicsShareAPI callbackInit()
|
||||
{
|
||||
static threadOnceId callbackOnceFlag = OSITHREAD_ONCE_INIT;
|
||||
static epicsThreadOnceId callbackOnceFlag = EPICS_THREAD_ONCE_INIT;
|
||||
void *arg = 0;
|
||||
threadOnce(&callbackOnceFlag,callbackInitPvt,arg);
|
||||
epicsThreadOnce(&callbackOnceFlag,callbackInitPvt,arg);
|
||||
}
|
||||
|
||||
/* Routine which places requests into callback queue*/
|
||||
@@ -137,9 +137,9 @@ static void start(int ind)
|
||||
char taskName[20];
|
||||
|
||||
callbackSem[ind] = epicsEventMustCreate(epicsEventEmpty);
|
||||
if(ind==0) priority = threadPriorityScanLow - 1;
|
||||
else if(ind==1) priority = threadPriorityScanLow +4;
|
||||
else if(ind==2) priority = threadPriorityScanHigh + 1;
|
||||
if(ind==0) priority = epicsThreadPriorityScanLow - 1;
|
||||
else if(ind==1) priority = epicsThreadPriorityScanLow +4;
|
||||
else if(ind==2) priority = epicsThreadPriorityScanHigh + 1;
|
||||
else {
|
||||
errMessage(0,"callback start called with illegal priority\n");
|
||||
return;
|
||||
@@ -147,8 +147,8 @@ static void start(int ind)
|
||||
if((callbackQ[ind]=epicsRingPointerCreate(callbackQueueSize)) == 0)
|
||||
errMessage(0,"epicsRingPointerCreate failed while starting a callback task");
|
||||
sprintf(taskName,"cb%s",priorityName[ind]);
|
||||
callbackTaskId[ind] = threadCreate(taskName,priority,
|
||||
threadGetStackSize(threadStackBig),(THREADFUNC)callbackTask,
|
||||
callbackTaskId[ind] = epicsThreadCreate(taskName,priority,
|
||||
epicsThreadGetStackSize(epicsThreadStackBig),(EPICSTHREADFUNC)callbackTask,
|
||||
&priorityValue[ind]);
|
||||
if(callbackTaskId[ind]==0) {
|
||||
errMessage(0,"Failed to spawn a callback task");
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ of this distribution.
|
||||
#include <string.h>
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "osiThread.h"
|
||||
#include "epicsThread.h"
|
||||
#include "errlog.h"
|
||||
#include "cantProceed.h"
|
||||
#include "cvtFast.h"
|
||||
|
||||
+12
-9
@@ -14,6 +14,9 @@ of this distribution.
|
||||
/* Modification Log:
|
||||
* -----------------
|
||||
* $Log$
|
||||
* Revision 1.25 2001/01/12 00:27:16 jhill
|
||||
* fixed bugs introduced by APS's osi => epics name changes
|
||||
*
|
||||
* Revision 1.24 2001/01/11 16:11:21 mrk
|
||||
* replace osiSem with epicsMutex and/or epicsEvent
|
||||
*
|
||||
@@ -33,7 +36,7 @@ of this distribution.
|
||||
* changes for creating win dlls
|
||||
*
|
||||
* Revision 1.18 2000/02/26 23:45:22 norume
|
||||
* Reflect routine name change from threadSuspend() to threadSuspendSelf().
|
||||
* Reflect routine name change from threadSuspend() to epicsThreadSuspendSelf().
|
||||
*
|
||||
* Revision 1.17 2000/02/25 22:26:38 mrk
|
||||
* more changes for creating dlls
|
||||
@@ -107,7 +110,7 @@ of this distribution.
|
||||
#include <string.h>
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "osiThread.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "tsStamp.h"
|
||||
@@ -426,9 +429,9 @@ long epicsShareAPI dbb(const char *record_name)
|
||||
/*
|
||||
* Spawn continuation task
|
||||
*/
|
||||
pnode->taskid = threadCreate("bkptCont",threadPriorityScanLow-1,
|
||||
threadGetStackSize(threadStackBig),
|
||||
(THREADFUNC)dbBkptCont,precord);
|
||||
pnode->taskid = epicsThreadCreate("bkptCont",epicsThreadPriorityScanLow-1,
|
||||
epicsThreadGetStackSize(epicsThreadStackBig),
|
||||
(EPICSTHREADFUNC)dbBkptCont,precord);
|
||||
if (pnode->taskid == 0) {
|
||||
printf(" BKPT> Cannot spawn task to process record\n");
|
||||
pnode->taskid = 0;
|
||||
@@ -567,7 +570,7 @@ long epicsShareAPI dbc(const char *record_name)
|
||||
* for a record with a breakpoint. This occurs
|
||||
* because stepping mode has been switched off.
|
||||
*/
|
||||
threadResume(pnode->taskid);
|
||||
epicsThreadResume(pnode->taskid);
|
||||
epicsMutexUnlock(bkpt_stack_sem);
|
||||
return(0);
|
||||
}
|
||||
@@ -596,7 +599,7 @@ long epicsShareAPI dbs(const char *record_name)
|
||||
|
||||
last_lset = pnode->l_num;
|
||||
|
||||
threadResume(pnode->taskid);
|
||||
epicsThreadResume(pnode->taskid);
|
||||
epicsMutexUnlock(bkpt_stack_sem);
|
||||
return(0);
|
||||
}
|
||||
@@ -758,7 +761,7 @@ int epicsShareAPI dbBkpt(dbCommon *precord)
|
||||
* source, queue its execution, but dump out of dbProcess without
|
||||
* calling record support.
|
||||
*/
|
||||
if (pnode->taskid && (threadGetIdSelf() != pnode->taskid)) {
|
||||
if (pnode->taskid && (epicsThreadGetIdSelf() != pnode->taskid)) {
|
||||
/* CONTINUE TASK CANNOT ENTER HERE */
|
||||
|
||||
/*
|
||||
@@ -855,7 +858,7 @@ int epicsShareAPI dbBkpt(dbCommon *precord)
|
||||
*/
|
||||
epicsMutexUnlock(bkpt_stack_sem);
|
||||
dbScanUnlock(precord);
|
||||
threadSuspendSelf();
|
||||
epicsThreadSuspendSelf();
|
||||
dbScanLock(precord);
|
||||
epicsMutexMustLock(bkpt_stack_sem);
|
||||
}
|
||||
|
||||
+5
-1
@@ -32,6 +32,10 @@
|
||||
#ifndef INCdbBkptsh
|
||||
#define INCdbBkptsh 1
|
||||
|
||||
#include "ellLib.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsThread.h"
|
||||
#include "tsStamp.h"
|
||||
#include "shareLib.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -73,7 +77,7 @@ struct LS_LIST {
|
||||
ELLLIST bp_list; /* list of records containing breakpoints in a lockset */
|
||||
ELLLIST ep_queue; /* queue of entrypoints found so far */
|
||||
epicsEventId ex_sem; /* semaphore for execution queue */
|
||||
threadId taskid; /* saved taskid for the task in stepping mode */
|
||||
epicsThreadId taskid; /* saved taskid for the task in stepping mode */
|
||||
int step; /* one if currently "stepping," else zero */
|
||||
unsigned long l_num; /* lockset number */
|
||||
};
|
||||
|
||||
+5
-5
@@ -33,7 +33,7 @@ of this distribution.
|
||||
#include "dbDefs.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "osiThread.h"
|
||||
#include "epicsThread.h"
|
||||
#include "tsStamp.h"
|
||||
#include "errlog.h"
|
||||
#include "taskwd.h"
|
||||
@@ -85,8 +85,8 @@ void epicsShareAPI dbCaLinkInit(void)
|
||||
ellInit(&caList);
|
||||
caListSem = epicsMutexMustCreate();
|
||||
caWakeupSem = epicsEventMustCreate(epicsEventEmpty);
|
||||
threadCreate("dbCaLink", threadPriorityMedium,
|
||||
threadGetStackSize(threadStackBig), (THREADFUNC) dbCaTask,0);
|
||||
epicsThreadCreate("dbCaLink", epicsThreadPriorityMedium,
|
||||
epicsThreadGetStackSize(epicsThreadStackBig), (EPICSTHREADFUNC) dbCaTask,0);
|
||||
}
|
||||
|
||||
void epicsShareAPI dbCaAddLink( struct link *plink)
|
||||
@@ -627,13 +627,13 @@ void dbCaTask()
|
||||
short link_action;
|
||||
int status;
|
||||
|
||||
taskwdInsert(threadGetIdSelf(),NULL,NULL);
|
||||
taskwdInsert(epicsThreadGetIdSelf(),NULL,NULL);
|
||||
SEVCHK(ca_context_create(enablePreemption),
|
||||
"dbCaTask calling ca_context_create");
|
||||
SEVCHK(ca_add_exception_event(exceptionCallback,NULL),
|
||||
"ca_add_exception_event");
|
||||
/*Dont do anything until iocInit initializes database*/
|
||||
while(!interruptAccept) threadSleep(.1);
|
||||
while(!interruptAccept) epicsThreadSleep(.1);
|
||||
/* channel access event loop */
|
||||
while (TRUE){
|
||||
epicsEventMustWait(caWakeupSem);
|
||||
|
||||
+9
-9
@@ -29,7 +29,7 @@ of this distribution.
|
||||
#include "dbDefs.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "osiThread.h"
|
||||
#include "epicsThread.h"
|
||||
#include "errlog.h"
|
||||
#include "taskwd.h"
|
||||
#include "freeList.h"
|
||||
@@ -97,13 +97,13 @@ struct event_user {
|
||||
EXTRALABORFUNC *extralabor_sub;/* off load to event task */
|
||||
void *extralabor_arg;/* parameter to above */
|
||||
|
||||
threadId taskid; /* event handler task id */
|
||||
epicsThreadId taskid; /* event handler task id */
|
||||
unsigned queovr; /* event que overflow count */
|
||||
unsigned char pendexit; /* exit pend task */
|
||||
unsigned char extra_labor; /* if set call extra labor func */
|
||||
unsigned char flowCtrlMode; /* replace existing monitor */
|
||||
void (*init_func)();
|
||||
threadId init_func_arg;
|
||||
epicsThreadId init_func_arg;
|
||||
};
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ int epicsShareAPI db_flush_extra_labor_event (dbEventCtx ctx)
|
||||
struct event_user *evUser = (struct event_user *) ctx;
|
||||
|
||||
while(evUser->extra_labor){
|
||||
threadSleep(1.0);
|
||||
epicsThreadSleep(1.0);
|
||||
}
|
||||
|
||||
return DB_EVENT_OK;
|
||||
@@ -880,7 +880,7 @@ LOCAL void event_task (void *pParm)
|
||||
(*evUser->init_func)(evUser->init_func_arg);
|
||||
}
|
||||
|
||||
taskwdInsert ( threadGetIdSelf(), NULL, NULL );
|
||||
taskwdInsert ( epicsThreadGetIdSelf(), NULL, NULL );
|
||||
|
||||
do{
|
||||
epicsEventMustWait(evUser->ppendsem);
|
||||
@@ -936,7 +936,7 @@ LOCAL void event_task (void *pParm)
|
||||
|
||||
freeListFree(dbevEventUserFreeList, evUser);
|
||||
|
||||
taskwdRemove(threadGetIdSelf());
|
||||
taskwdRemove(epicsThreadGetIdSelf());
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -945,7 +945,7 @@ LOCAL void event_task (void *pParm)
|
||||
* DB_START_EVENTS()
|
||||
*/
|
||||
int epicsShareAPI db_start_events (
|
||||
dbEventCtx ctx,const char *taskname, void (*init_func)(threadId),
|
||||
dbEventCtx ctx,const char *taskname, void (*init_func)(epicsThreadId),
|
||||
void *init_func_arg, unsigned osiPriority )
|
||||
{
|
||||
struct event_user *evUser = (struct event_user *) ctx;
|
||||
@@ -967,8 +967,8 @@ int epicsShareAPI db_start_events (
|
||||
if (!taskname) {
|
||||
taskname = EVENT_PEND_NAME;
|
||||
}
|
||||
evUser->taskid = threadCreate (
|
||||
taskname, osiPriority, threadGetStackSize(threadStackMedium),
|
||||
evUser->taskid = epicsThreadCreate (
|
||||
taskname, osiPriority, epicsThreadGetStackSize(epicsThreadStackMedium),
|
||||
event_task, (void *)evUser);
|
||||
if (!evUser->taskid) {
|
||||
epicsMutexUnlock (evUser->firstque.writelock);
|
||||
|
||||
+8
-8
@@ -68,7 +68,7 @@ since this will delay all other threads.
|
||||
#include "dbBase.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "tsStamp.h"
|
||||
#include "osiThread.h"
|
||||
#include "epicsThread.h"
|
||||
#include "cantProceed.h"
|
||||
#include "ellLib.h"
|
||||
#include "dbBase.h"
|
||||
@@ -96,7 +96,7 @@ typedef struct lockSet {
|
||||
ELLNODE node;
|
||||
ELLLIST recordList;
|
||||
epicsMutexId lock;
|
||||
threadId thread_id;
|
||||
epicsThreadId thread_id;
|
||||
dbCommon *precord;
|
||||
unsigned long id;
|
||||
} lockSet;
|
||||
@@ -166,11 +166,11 @@ void epicsShareAPI dbLockSetRecordLock(dbCommon *precord)
|
||||
if(!plockRecord) return;
|
||||
plockSet = plockRecord->plockSet;
|
||||
if(!plockSet) return;
|
||||
if(plockSet->thread_id==threadGetIdSelf()) return;
|
||||
if(plockSet->thread_id==epicsThreadGetIdSelf()) return;
|
||||
/*Wait for up to 1 minute*/
|
||||
status = epicsMutexLockWithTimeout(plockRecord->plockSet->lock,60.0);
|
||||
if(status==epicsMutexLockOK) {
|
||||
plockSet->thread_id = threadGetIdSelf();
|
||||
plockSet->thread_id = epicsThreadGetIdSelf();
|
||||
plockSet->precord = (void *)precord;
|
||||
/*give it back in case it will not be changed*/
|
||||
epicsMutexUnlock(plockRecord->plockSet->lock);
|
||||
@@ -178,7 +178,7 @@ void epicsShareAPI dbLockSetRecordLock(dbCommon *precord)
|
||||
}
|
||||
/*Should never reach this point*/
|
||||
errlogPrintf("dbLockSetRecordLock timeout caller 0x%x owner 0x%x",
|
||||
threadGetIdSelf(),plockSet->thread_id);
|
||||
epicsThreadGetIdSelf(),plockSet->thread_id);
|
||||
errlogPrintf(" record %s\n",precord->name);
|
||||
cantProceed("dbLockSetRecordLock");
|
||||
}
|
||||
@@ -192,16 +192,16 @@ void epicsShareAPI dbScanLock(dbCommon *precord)
|
||||
if(!(plockRecord= precord->lset)) {
|
||||
epicsPrintf("dbScanLock plockRecord is NULL record %s\n",
|
||||
precord->name);
|
||||
threadSuspendSelf();
|
||||
epicsThreadSuspendSelf();
|
||||
}
|
||||
while(TRUE) {
|
||||
while(changingLockSets) threadSleep(.05);
|
||||
while(changingLockSets) epicsThreadSleep(.05);
|
||||
status = epicsMutexLock(plockRecord->plockSet->lock);
|
||||
/*epicsMutexLock fails if epicsMutexDestroy was called while active*/
|
||||
if(status==epicsMutexLockOK) break;
|
||||
}
|
||||
plockSet = plockRecord->plockSet;
|
||||
plockSet->thread_id = threadGetIdSelf();
|
||||
plockSet->thread_id = epicsThreadGetIdSelf();
|
||||
plockSet->precord = (void *)precord;
|
||||
return;
|
||||
}
|
||||
|
||||
+11
-11
@@ -55,7 +55,7 @@
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "osiInterrupt.h"
|
||||
#include "osiThread.h"
|
||||
#include "epicsThread.h"
|
||||
#include "tsStamp.h"
|
||||
#include "cantProceed.h"
|
||||
#include "epicsRingPointer.h"
|
||||
@@ -79,7 +79,7 @@
|
||||
int onceQueueSize = 1000;
|
||||
static epicsEventId onceSem;
|
||||
static epicsRingPointerId onceQ;
|
||||
static threadId onceTaskId;
|
||||
static epicsThreadId onceTaskId;
|
||||
|
||||
/*all other scan types */
|
||||
typedef struct scan_list{
|
||||
@@ -117,7 +117,7 @@ static io_scan_list *iosl_head[NUM_CALLBACK_PRIORITIES]={NULL,NULL,NULL};
|
||||
/* PERIODIC SCANNER */
|
||||
static int nPeriodic=0;
|
||||
static scan_list **papPeriodic; /* pointer to array of pointers*/
|
||||
static threadId *periodicTaskId; /*array of thread ids*/
|
||||
static epicsThreadId *periodicTaskId; /*array of thread ids*/
|
||||
|
||||
/* Private routines */
|
||||
static void onceTask(void);
|
||||
@@ -485,9 +485,9 @@ static void initOnce(void)
|
||||
cantProceed("dbScan: initOnce failed");
|
||||
}
|
||||
onceSem=epicsEventMustCreate(epicsEventEmpty);
|
||||
onceTaskId = threadCreate("scanOnce",threadPriorityScanHigh,
|
||||
threadGetStackSize(threadStackBig),
|
||||
(THREADFUNC)onceTask,0);
|
||||
onceTaskId = epicsThreadCreate("scanOnce",epicsThreadPriorityScanHigh,
|
||||
epicsThreadGetStackSize(epicsThreadStackBig),
|
||||
(EPICSTHREADFUNC)onceTask,0);
|
||||
taskwdInsert(onceTaskId,NULL,0L);
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ static void periodicTask(void *arg)
|
||||
diff = tsStampDiffInSeconds(&end_time,&start_time);
|
||||
delay = psl->rate - diff;
|
||||
delay = (delay<=0.0) ? .1 : delay;
|
||||
threadSleep(delay);
|
||||
epicsThreadSleep(delay);
|
||||
tsStampGetCurrent(&start_time);
|
||||
}
|
||||
}
|
||||
@@ -548,11 +548,11 @@ static void spawnPeriodic(int ind)
|
||||
while(taskName[strlen(taskName)-1]=='0') taskName[strlen(taskName)-1] = 0;
|
||||
/*strip trailing . */
|
||||
if(taskName[strlen(taskName)-1]=='.') taskName[strlen(taskName)-1] = 0;
|
||||
periodicTaskId[ind] = threadCreate(
|
||||
periodicTaskId[ind] = epicsThreadCreate(
|
||||
taskName,
|
||||
threadPriorityScanLow + ind,
|
||||
threadGetStackSize(threadStackBig),
|
||||
(THREADFUNC)periodicTask,
|
||||
epicsThreadPriorityScanLow + ind,
|
||||
epicsThreadGetStackSize(epicsThreadStackBig),
|
||||
(EPICSTHREADFUNC)periodicTask,
|
||||
(void *)psl);
|
||||
taskwdInsert(periodicTaskId[ind],NULL,0L);
|
||||
}
|
||||
|
||||
@@ -132,10 +132,10 @@ dbEventSubscription dbServiceIO::subscribe ( struct dbAddr &addr, dbSubscription
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned selfPriority = threadGetPrioritySelf ();
|
||||
unsigned selfPriority = epicsThreadGetPrioritySelf ();
|
||||
unsigned above;
|
||||
threadBoolStatus tbs = threadLowestPriorityLevelAbove (selfPriority, &above);
|
||||
if ( tbs != tbsSuccess ) {
|
||||
epicsThreadBooleanStatus tbs = epicsThreadLowestPriorityLevelAbove (selfPriority, &above);
|
||||
if ( tbs != epicsThreadBooleanStatusSuccess ) {
|
||||
above = selfPriority;
|
||||
}
|
||||
status = db_start_events ( this->ctx, "CAC-event",
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "dbDefs.h"
|
||||
#include "osiThread.h"
|
||||
#include "tsStamp.h"
|
||||
#include "epicsPrint.h"
|
||||
#include "dbBase.h"
|
||||
|
||||
@@ -14,7 +14,7 @@ of this distribution.
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "osiThread.h"
|
||||
#include "epicsThread.h"
|
||||
#include "errlog.h"
|
||||
#include "callback.h"
|
||||
#include "taskwd.h"
|
||||
@@ -68,6 +68,6 @@ void callbackTest(void)
|
||||
wait[i]->requestedDiff = (double)i;
|
||||
callbackRequestDelayed(&wait[i]->callback,wait[i]->requestedDiff);
|
||||
}
|
||||
threadSleep((double)(ncallbacks + 2));
|
||||
epicsThreadSleep((double)(ncallbacks + 2));
|
||||
printf("callbackTest returning\n");
|
||||
}
|
||||
|
||||
@@ -13,14 +13,12 @@ of this distribution.
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "osiThread.h"
|
||||
void *pdbbase=NULL;
|
||||
|
||||
void callbackTest(void);
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
threadInit();
|
||||
callbackTest();
|
||||
printf("main terminating\n");
|
||||
return(0);
|
||||
|
||||
Reference in New Issue
Block a user