diff --git a/src/as/asCa.c b/src/as/asCa.c index 425b6f176..992be6e9e 100644 --- a/src/as/asCa.c +++ b/src/as/asCa.c @@ -27,7 +27,8 @@ of this distribution. #include "dbDefs.h" #include "ellLib.h" #include "osiThread.h" -#include "osiSem.h" +#include "epicsMutex.h" +#include "epicsEvent.h" #include "cantProceed.h" #include "errlog.h" #include "taskwd.h" @@ -47,10 +48,10 @@ epicsShareDef int asCaDebug = 0; LOCAL int firstTime = TRUE; LOCAL threadId threadid=0; LOCAL int caInitializing=FALSE; -LOCAL semMutexId asCaTaskLock; /*lock access to task */ -LOCAL semBinaryId asCaTaskWait; /*Wait for task to respond*/ -LOCAL semBinaryId asCaTaskAddChannels; /*Tell asCaTask to add channels*/ -LOCAL semBinaryId asCaTaskClearChannels;/*Tell asCaTask to clear channels*/ +LOCAL epicsMutexId asCaTaskLock; /*lock access to task */ +LOCAL epicsEventId asCaTaskWait; /*Wait for task to respond*/ +LOCAL epicsEventId asCaTaskAddChannels; /*Tell asCaTask to add channels*/ +LOCAL epicsEventId asCaTaskClearChannels;/*Tell asCaTask to clear channels*/ typedef struct { struct dbr_sts_double rtndata; @@ -177,7 +178,7 @@ LOCAL void asCaTask(void) SEVCHK(ca_add_exception_event(exceptionCallback,NULL), "ca_add_exception_event"); while(TRUE) { - semBinaryMustTake(asCaTaskAddChannels); + epicsEventMustWait(asCaTaskAddChannels); caInitializing = TRUE; pasg = (ASG *)ellFirst(&pasbase->asgList); while(pasg) { @@ -206,9 +207,9 @@ LOCAL void asCaTask(void) asComputeAllAsg(); caInitializing = FALSE; if(asCaDebug) printf("asCaTask initialized\n"); - semBinaryGive(asCaTaskWait); + epicsEventSignal(asCaTaskWait); while(TRUE) { - if(semBinaryTakeNoWait(asCaTaskClearChannels)==semTakeOK) break; + if(epicsEventTryWait(asCaTaskClearChannels)==epicsEventWaitOK) break; ca_pend_event(2.0); } pasg = (ASG *)ellFirst(&pasbase->asgList); @@ -228,7 +229,7 @@ LOCAL void asCaTask(void) pasg = (ASG *)ellNext((ELLNODE *)pasg); } if(asCaDebug) printf("asCaTask has cleared all channels\n"); - semBinaryGive(asCaTaskWait); + epicsEventSignal(asCaTaskWait); } } @@ -237,10 +238,10 @@ void epicsShareAPI asCaStart(void) if(asCaDebug) printf("asCaStart called\n"); if(firstTime) { firstTime = FALSE; - asCaTaskLock=semMutexMustCreate(); - asCaTaskWait=semBinaryMustCreate(semEmpty); - asCaTaskAddChannels=semBinaryMustCreate(semEmpty); - asCaTaskClearChannels=semBinaryMustCreate(semEmpty); + asCaTaskLock=epicsMutexMustCreate(); + asCaTaskWait=epicsEventMustCreate(epicsEventEmpty); + asCaTaskAddChannels=epicsEventMustCreate(epicsEventEmpty); + asCaTaskClearChannels=epicsEventMustCreate(epicsEventEmpty); threadid = threadCreate("asCaTask", (threadPriorityScanLow - 3), threadGetStackSize(threadStackBig), @@ -249,20 +250,20 @@ void epicsShareAPI asCaStart(void) errMessage(0,"asCaStart: taskSpawn Failure\n"); } } - semMutexMustTake(asCaTaskLock); - semBinaryGive(asCaTaskAddChannels); - semBinaryMustTake(asCaTaskWait); + epicsMutexMustLock(asCaTaskLock); + epicsEventSignal(asCaTaskAddChannels); + epicsEventMustWait(asCaTaskWait); if(asCaDebug) printf("asCaStart done\n"); - semMutexGive(asCaTaskLock); + epicsMutexUnlock(asCaTaskLock); } void epicsShareAPI asCaStop(void) { if(threadid==0) return; if(asCaDebug) printf("asCaStop called\n"); - semMutexMustTake(asCaTaskLock); - semBinaryGive(asCaTaskClearChannels); - semBinaryMustTake(asCaTaskWait); + epicsMutexMustLock(asCaTaskLock); + epicsEventSignal(asCaTaskClearChannels); + epicsEventMustWait(asCaTaskWait); if(asCaDebug) printf("asCaStop done\n"); - semMutexGive(asCaTaskLock); + epicsMutexUnlock(asCaTaskLock); } diff --git a/src/as/asLibRoutines.c b/src/as/asLibRoutines.c index ce97c5e19..0c1923963 100644 --- a/src/as/asLibRoutines.c +++ b/src/as/asLibRoutines.c @@ -28,7 +28,7 @@ of this distribution. #include "osiThread.h" #include "ellLib.h" #include "cantProceed.h" -#include "osiSem.h" +#include "epicsMutex.h" #include "epicsPrint.h" #include "gpHash.h" #include "freeList.h" @@ -37,9 +37,9 @@ of this distribution. #include "errlog.h" #include "ellLib.h" -static semMutexId asLock; -#define LOCK semMutexMustTake(asLock) -#define UNLOCK semMutexGive(asLock) +static epicsMutexId asLock; +#define LOCK epicsMutexMustLock(asLock) +#define UNLOCK epicsMutexUnlock(asLock) #define epicsExportSharedSymbols #include "asLib.h" @@ -88,7 +88,7 @@ static long asAsgRuleCalc(ASGRULE *pasgrule,char *calc); */ static void asInitializeOnce(void *arg) { - asLock = semMutexMustCreate(); + asLock = epicsMutexMustCreate(); } long epicsShareAPI asInitialize(ASINPUTFUNCPTR inputfunction) { diff --git a/src/as/asTrapWrite.c b/src/as/asTrapWrite.c index 02f69163d..db28b5d3b 100644 --- a/src/as/asTrapWrite.c +++ b/src/as/asTrapWrite.c @@ -24,7 +24,7 @@ of this distribution. #include "ellLib.h" #include "freeList.h" #include "cantProceed.h" -#include "osiSem.h" +#include "epicsMutex.h" #include "ellLib.h" #define epicsExportSharedSymbols #include "asLib.h" @@ -54,7 +54,7 @@ typedef struct asTrapWritePvt ELLLIST writeMessageList; void *freeListWriteMessage; void *freeListListenerPvt; - semMutexId lock; + epicsMutexId lock; }asTrapWritePvt; static asTrapWritePvt *pasTrapWritePvt = 0; @@ -68,7 +68,7 @@ static void asTrapWriteInit(void) &pasTrapWritePvt->freeListWriteMessage,sizeof(writeMessage),20); freeListInitPvt( &pasTrapWritePvt->freeListListenerPvt,sizeof(listenerPvt),20); - pasTrapWritePvt->lock = semMutexMustCreate(); + pasTrapWritePvt->lock = epicsMutexMustCreate(); } asTrapWriteId epicsShareAPI asTrapWriteRegisterListener( @@ -78,9 +78,9 @@ asTrapWriteId epicsShareAPI asTrapWriteRegisterListener( if(pasTrapWritePvt==0) asTrapWriteInit(); plistener = callocMustSucceed(1,sizeof(listener),"asTrapWriteRegisterListener"); plistener->func = func; - semMutexMustTake(pasTrapWritePvt->lock); + epicsMutexMustLock(pasTrapWritePvt->lock); ellAdd(&pasTrapWritePvt->listenerList,&plistener->node); - semMutexGive(pasTrapWritePvt->lock); + epicsMutexUnlock(pasTrapWritePvt->lock); return((asTrapWriteId)plistener); } @@ -90,7 +90,7 @@ void epicsShareAPI asTrapWriteUnregisterListener(asTrapWriteId id) writeMessage *pwriteMessage; if(pasTrapWritePvt==0) return; - semMutexMustTake(pasTrapWritePvt->lock); + epicsMutexMustLock(pasTrapWritePvt->lock); pwriteMessage = (writeMessage *)ellFirst(&pasTrapWritePvt->writeMessageList); while(pwriteMessage) { listenerPvt *plistenerPvt @@ -108,7 +108,7 @@ void epicsShareAPI asTrapWriteUnregisterListener(asTrapWriteId id) } ellDelete(&pasTrapWritePvt->listenerList,&plistener->node); free((void *)plistener); - semMutexGive(pasTrapWritePvt->lock); + epicsMutexUnlock(pasTrapWritePvt->lock); } void * epicsShareAPI asTrapWriteBeforeWrite( @@ -126,7 +126,7 @@ void * epicsShareAPI asTrapWriteBeforeWrite( pwriteMessage->message.hostid = hostid; pwriteMessage->message.serverSpecific = addr; ellInit(&pwriteMessage->listenerPvtList); - semMutexMustTake(pasTrapWritePvt->lock); + epicsMutexMustLock(pasTrapWritePvt->lock); ellAdd(&pasTrapWritePvt->writeMessageList,&pwriteMessage->node); plistener = (listener *)ellFirst(&pasTrapWritePvt->listenerList); while(plistener) { @@ -139,7 +139,7 @@ void * epicsShareAPI asTrapWriteBeforeWrite( ellAdd(&pwriteMessage->listenerPvtList,&plistenerPvt->node); plistener = (listener *)ellNext(&plistener->node); } - semMutexGive(pasTrapWritePvt->lock); + epicsMutexUnlock(pasTrapWritePvt->lock); return((void *)pwriteMessage); } @@ -149,7 +149,7 @@ void epicsShareAPI asTrapWriteAfterWrite(void *pvt) listenerPvt *plistenerPvt; if(pwriteMessage==0 || pasTrapWritePvt==0) return; - semMutexMustTake(pasTrapWritePvt->lock); + epicsMutexMustLock(pasTrapWritePvt->lock); plistenerPvt = (listenerPvt *)ellFirst(&pwriteMessage->listenerPvtList); while(plistenerPvt) { listenerPvt *pnext = (listenerPvt *)ellNext(&plistenerPvt->node); @@ -163,5 +163,5 @@ void epicsShareAPI asTrapWriteAfterWrite(void *pvt) } ellDelete(&pasTrapWritePvt->writeMessageList,&pwriteMessage->node); freeListFree(pasTrapWritePvt->freeListWriteMessage,(void *)pwriteMessage); - semMutexGive(pasTrapWritePvt->lock); + epicsMutexUnlock(pasTrapWritePvt->lock); } diff --git a/src/db/callback.c b/src/db/callback.c index c9349c864..892c16bc4 100644 --- a/src/db/callback.c +++ b/src/db/callback.c @@ -18,7 +18,7 @@ of this distribution. #include #include "dbDefs.h" -#include "osiSem.h" +#include "epicsEvent.h" #include "osiThread.h" #include "osiInterrupt.h" #include "osiTimer.h" @@ -40,7 +40,7 @@ of this distribution. #include "callback.h" int callbackQueueSize = 2000; -static semBinaryId callbackSem[NUM_CALLBACK_PRIORITIES]; +static epicsEventId callbackSem[NUM_CALLBACK_PRIORITIES]; static epicsRingPointerId callbackQ[NUM_CALLBACK_PRIORITIES]; static threadId callbackTaskId[NUM_CALLBACK_PRIORITIES]; static int ringOverflow[NUM_CALLBACK_PRIORITIES]; @@ -107,7 +107,7 @@ void epicsShareAPI callbackRequest(CALLBACK *pcallback) epicsPrintf("callbackRequest ring buffer full\n"); ringOverflow[priority] = TRUE; } - semBinaryGive(callbackSem[priority]); + epicsEventSignal(callbackSem[priority]); return; } @@ -120,7 +120,7 @@ static void callbackTask(int *ppriority) ringOverflow[priority] = FALSE; while(TRUE) { /* wait for somebody to wake us up */ - semBinaryMustTake(callbackSem[priority]); + epicsEventMustWait(callbackSem[priority]); while(TRUE) { if(!(pcallback = (CALLBACK *) epicsRingPointerPop(callbackQ[priority]))) break; @@ -136,7 +136,7 @@ static void start(int ind) unsigned int priority; char taskName[20]; - callbackSem[ind] = semBinaryMustCreate(semEmpty); + callbackSem[ind] = epicsEventMustCreate(epicsEventEmpty); if(ind==0) priority = threadPriorityScanLow - 1; else if(ind==1) priority = threadPriorityScanLow +4; else if(ind==2) priority = threadPriorityScanHigh + 1; @@ -163,7 +163,7 @@ static void wdCallback(void *pind) int ind = *(int *)pind; taskwdRemove(callbackTaskId[ind]); if(!callbackRestart)return; - semBinaryDestroy(callbackSem[ind]); + epicsEventDestroy(callbackSem[ind]); epicsRingPointerDelete(callbackQ[ind]); start(ind); } diff --git a/src/db/dbAccess.c b/src/db/dbAccess.c index 2219ed9ab..60026cc92 100644 --- a/src/db/dbAccess.c +++ b/src/db/dbAccess.c @@ -72,6 +72,7 @@ of this distribution. #include "dbEvent.h" #include "dbConvert.h" #include "dbConvertFast.h" +#include "epicsEvent.h" #include "dbCa.h" #include "dbBkpt.h" #include "dbNotify.h" diff --git a/src/db/dbBkpt.c b/src/db/dbBkpt.c index 5f1139db9..43e75b846 100644 --- a/src/db/dbBkpt.c +++ b/src/db/dbBkpt.c @@ -14,6 +14,9 @@ of this distribution. /* Modification Log: * ----------------- * $Log$ + * Revision 1.23 2000/04/28 18:29:48 mrk + * add dbior; add support for c++ + * * Revision 1.22 2000/02/29 19:33:33 mrk * more changes for win32 build * @@ -39,7 +42,7 @@ of this distribution. * Remove task argument to threadSuspend(). * * Revision 1.14 2000/01/27 19:46:40 mrk - * semId => semBinaryId and semMutexId + * semId => semBinaryId and epicsMutexId * * Revision 1.13 2000/01/24 20:58:12 mrk * new way to build @@ -102,7 +105,8 @@ of this distribution. #include "dbDefs.h" #include "osiThread.h" -#include "osiSem.h" +#include "epicsMutex.h" +#include "epicsEvent.h" #include "tsStamp.h" #include "ellLib.h" #include "errlog.h" @@ -209,7 +213,7 @@ long lset_stack_not_empty = 0; * operating with this stack. */ static ELLLIST lset_stack; -static semMutexId bkpt_stack_sem; +static epicsMutexId bkpt_stack_sem; /* * Stores the last lockset continued or stepped from. @@ -347,9 +351,9 @@ long epicsShareAPI dbb(const char *record_name) */ if (! lset_stack_not_empty) { /* initialize list and semaphore */ - bkpt_stack_sem = semMutexCreate(); + bkpt_stack_sem = epicsMutexCreate(); if (bkpt_stack_sem == 0) { - printf(" BKPT> semMutexCreate failed\n"); + printf(" BKPT> epicsMutexCreate failed\n"); dbScanUnlock(precord); return(1); } @@ -357,7 +361,7 @@ long epicsShareAPI dbb(const char *record_name) lset_stack_not_empty = 1; } - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); FIND_LOCKSET(precord, pnode); @@ -367,7 +371,7 @@ long epicsShareAPI dbb(const char *record_name) if (pnode == NULL) { printf(" BKPT> Out of memory\n"); dbScanUnlock(precord); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(1); } pnode->precord = NULL; @@ -379,11 +383,11 @@ long epicsShareAPI dbb(const char *record_name) ellInit(&pnode->ep_queue); /* create execution semaphore */ - pnode->ex_sem = semBinaryMustCreate(semEmpty); + pnode->ex_sem = epicsEventCreate(epicsEventEmpty); if (pnode->ex_sem == NULL) { printf(" BKPT> Out of memory\n"); dbScanUnlock(precord); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(1); } @@ -400,7 +404,7 @@ long epicsShareAPI dbb(const char *record_name) if (pbl == NULL) { printf(" BKPT> Out of memory\n"); dbScanUnlock(precord); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(1); } pbl->precord = precord; @@ -426,12 +430,12 @@ long epicsShareAPI dbb(const char *record_name) printf(" BKPT> Cannot spawn task to process record\n"); pnode->taskid = 0; dbScanUnlock(precord); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(1); } } - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); dbScanUnlock(precord); return(0); } @@ -470,7 +474,7 @@ long epicsShareAPI dbd(const char *record_name) dbScanLock(precord); - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); FIND_LOCKSET(precord, pnode); @@ -479,7 +483,7 @@ long epicsShareAPI dbd(const char *record_name) printf(" BKPT> Logic Error in dbd()\n"); precord->bkpt &= BKPT_OFF_MASK; - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); dbScanUnlock(precord); return(S_db_bkptLogic); } @@ -502,7 +506,7 @@ long epicsShareAPI dbd(const char *record_name) if (pbl == NULL) { printf(" BKPT> Logic Error in dbd()\n"); precord->bkpt &= BKPT_OFF_MASK; - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); dbScanUnlock(precord); return(S_db_bkptLogic); } @@ -517,9 +521,9 @@ long epicsShareAPI dbd(const char *record_name) * to cause the bkptCont task to quit. */ if (ellCount(&pnode->bp_list) == 0) - semBinaryGive(pnode->ex_sem); + epicsEventSignal(pnode->ex_sem); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); dbScanUnlock(precord); return(0); @@ -537,11 +541,11 @@ long epicsShareAPI dbc(const char *record_name) struct dbCommon *precord = NULL; long status = 0; - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); status = FIND_CONT_NODE(record_name, &pnode, &precord); if (status) { - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(status); } @@ -561,7 +565,7 @@ long epicsShareAPI dbc(const char *record_name) * because stepping mode has been switched off. */ threadResume(pnode->taskid); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(0); } @@ -576,11 +580,11 @@ long epicsShareAPI dbs(const char *record_name) struct dbCommon *precord = NULL; long status = 0; - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); status = FIND_CONT_NODE(record_name, &pnode, &precord); if (status) { - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(status); } @@ -590,7 +594,7 @@ long epicsShareAPI dbs(const char *record_name) last_lset = pnode->l_num; threadResume(pnode->taskid); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(0); } @@ -612,7 +616,7 @@ static void dbBkptCont(dbCommon *precord) * Reset breakpoint, process record, and * reset bkpt field in record */ - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); FIND_LOCKSET(precord, pnode); @@ -628,13 +632,13 @@ static void dbBkptCont(dbCommon *precord) */ do { /* Give up semaphore before waiting to run ... */ - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); /* Wait to run */ - semBinaryMustTake(pnode->ex_sem); + epicsEventMustWait(pnode->ex_sem); /* Bkpt stack must still be stable ! */ - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); pqe = (struct EP_LIST *) ellFirst(&pnode->ep_queue); @@ -669,7 +673,7 @@ static void dbBkptCont(dbCommon *precord) ellFree(&pnode->ep_queue); /* remove execution semaphore */ - semBinaryDestroy(pnode->ex_sem); + epicsEventDestroy(pnode->ex_sem); printf("\n BKPT> End debug of lockset %lu\n-> ", pnode->l_num); @@ -684,7 +688,7 @@ static void dbBkptCont(dbCommon *precord) } if (lset_stack_not_empty) - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); } /* @@ -720,9 +724,9 @@ int epicsShareAPI dbBkpt(dbCommon *precord) * goodness breakpoint checking is turned off during * normal operation. */ - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); FIND_LOCKSET(precord, pnode); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); if (pnode == NULL) { /* no breakpoints in precord's lockset */ @@ -779,12 +783,12 @@ int epicsShareAPI dbBkpt(dbCommon *precord) /* * Take semaphore, wait on continuation task */ - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); /* Add entry to queue */ ellAdd(&pnode->ep_queue, (ELLNODE *)pqe); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); } else { if (pqe->count < MAX_EP_COUNT) @@ -800,7 +804,7 @@ int epicsShareAPI dbBkpt(dbCommon *precord) * Release the semaphore, letting the continuation * task begin execution of the new entrypoint. */ - semBinaryGive(pnode->ex_sem); + epicsEventSignal(pnode->ex_sem); } return(1); } @@ -846,11 +850,11 @@ int epicsShareAPI dbBkpt(dbCommon *precord) * continue to be processed. Cross your fingers, this * might actually work ! */ - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); dbScanUnlock(precord); threadSuspendSelf(); dbScanLock(precord); - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); } return(0); } @@ -881,19 +885,19 @@ long epicsShareAPI dbp(const char *record_name, int interest_level) struct dbCommon *precord; int status; - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); /* find pnode and precord pointers */ status = FIND_CONT_NODE(record_name, &pnode, &precord); if (status) { - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(status); } /* print out record's fields */ dbpr(precord->name, (interest_level == 0) ? 2 : interest_level); - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(0); } @@ -937,7 +941,7 @@ long epicsShareAPI dbstat(void) struct EP_LIST *pqe; TS_STAMP time; - semMutexMustTake(bkpt_stack_sem); + epicsMutexMustLock(bkpt_stack_sem); tsStampGetCurrent(&time); @@ -986,7 +990,7 @@ long epicsShareAPI dbstat(void) pnode = (struct LS_LIST *) ellNext((ELLNODE *)pnode); } - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(0); } @@ -1022,7 +1026,7 @@ long epicsShareAPI dbprc(char *record_name) /* Reset breakpoints */ int dbreset() { - semMutexGive(bkpt_stack_sem); + epicsMutexUnlock(bkpt_stack_sem); return(0); } diff --git a/src/db/dbBkpt.h b/src/db/dbBkpt.h index 588eb8f93..dac6221d1 100644 --- a/src/db/dbBkpt.h +++ b/src/db/dbBkpt.h @@ -72,7 +72,7 @@ struct LS_LIST { struct dbCommon *current_ep; /* current entrypoint */ ELLLIST bp_list; /* list of records containing breakpoints in a lockset */ ELLLIST ep_queue; /* queue of entrypoints found so far */ - semBinaryId ex_sem; /* semaphore for execution queue */ + epicsEventId ex_sem; /* semaphore for execution queue */ threadId taskid; /* saved taskid for the task in stepping mode */ int step; /* one if currently "stepping," else zero */ unsigned long l_num; /* lockset number */ diff --git a/src/db/dbCa.c b/src/db/dbCa.c index dc15cb8ad..4506c4da1 100644 --- a/src/db/dbCa.c +++ b/src/db/dbCa.c @@ -31,7 +31,8 @@ of this distribution. #include #include "dbDefs.h" -#include "osiSem.h" +#include "epicsMutex.h" +#include "epicsEvent.h" #include "osiThread.h" #include "tsStamp.h" #include "errlog.h" @@ -51,8 +52,8 @@ epicsShareFunc void * epicsShareAPI dbCalloc(size_t nobj,size_t size); #include "dbCaPvt.h" static ELLLIST caList; /* Work list for dbCaTask */ -static semMutexId caListSem; /*Mutual exclusions semaphores for caList*/ -static semBinaryId caWakeupSem; /*wakeup semaphore for dbCaTask*/ +static epicsMutexId caListSem; /*Mutual exclusions semaphores for caList*/ +static epicsEventId caWakeupSem; /*wakeup semaphore for dbCaTask*/ void dbCaTask(void); /*The Channel Access Task*/ /* caLink locking @@ -69,24 +70,20 @@ static void addAction(caLink *pca, short link_action) { int callAdd = FALSE; - semMutexMustTake(caListSem); + epicsMutexMustLock(caListSem); if(pca->link_action==0) callAdd = TRUE; pca->link_action |= link_action; if(callAdd) ellAdd(&caList,&pca->node); - semMutexGive(caListSem); - if(callAdd) semBinaryGive(caWakeupSem); + epicsMutexUnlock(caListSem); + if(callAdd) epicsEventSignal(caWakeupSem); } void epicsShareAPI dbCaLinkInit(void) { dbServiceIOInit(); ellInit(&caList); - caListSem = semMutexMustCreate(); - caWakeupSem = semBinaryMustCreate(semEmpty); - if(!caListSem || !caWakeupSem) { - printf("dbCaLinkInit: semBCreate failed\n"); - return; - } + caListSem = epicsMutexMustCreate(); + caWakeupSem = epicsEventMustCreate(epicsEventEmpty); threadCreate("dbCaLink", threadPriorityMedium, threadGetStackSize(threadStackBig), (THREADFUNC) dbCaTask,0); } @@ -99,7 +96,7 @@ void epicsShareAPI dbCaAddLink( struct link *plink) pca->plink = plink; plink->type = CA_LINK; plink->value.pv_link.pvt = pca; - pca->lock = semMutexMustCreate(); + pca->lock = epicsMutexMustCreate(); addAction(pca,CA_CONNECT); return; } @@ -109,10 +106,10 @@ void epicsShareAPI dbCaRemoveLink( struct link *plink) caLink *pca = (caLink *)plink->value.pv_link.pvt; if(!pca) return; - semMutexMustTake(pca->lock); + epicsMutexMustLock(pca->lock); pca->plink = 0; plink->value.pv_link.pvt = 0; - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); addAction(pca,CA_DELETE); } @@ -130,7 +127,7 @@ long epicsShareAPI dbCaGetLink(struct link *plink,short dbrType, void *pdest, plink->value.pv_link.precord); return(-1); } - semMutexMustTake(pca->lock); + epicsMutexMustLock(pca->lock); if(!pca->chid || ca_state(pca->chid) != cs_conn) { pca->sevr = INVALID_ALARM; goto done; @@ -182,7 +179,7 @@ long epicsShareAPI dbCaGetLink(struct link *plink,short dbrType, void *pdest, } done: if(psevr) *psevr = pca->sevr; - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); if(link_action) addAction(pca,link_action); return(status); } @@ -201,9 +198,9 @@ long epicsShareAPI dbCaPutLink(struct link *plink,short dbrType, return(-1); } /* put the new value in */ - semMutexMustTake(pca->lock); + epicsMutexMustLock(pca->lock); if(!pca->chid || ca_state(pca->chid) != cs_conn) { - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); return(-1); } if((pca->dbrType == DBR_ENUM) && (dbDBRnewToDBRold[dbrType] == DBR_STRING)){ @@ -243,7 +240,7 @@ long epicsShareAPI dbCaPutLink(struct link *plink,short dbrType, if(pca->newOutNative) pca->nNoWrite++; pca->newOutNative = TRUE; } - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); addAction(pca,link_action); return(status); } @@ -274,10 +271,10 @@ long epicsShareAPI dbCaGetAttributes(struct link *plink, pcaAttributes = dbCalloc(1,sizeof(caAttributes)); pcaAttributes->callback = callback; pcaAttributes->usrPvt = usrPvt; - semMutexMustTake(pca->lock); + epicsMutexMustLock(pca->lock); pca->pcaAttributes = pcaAttributes; link_action |= CA_GET_ATTRIBUTES; - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); addAction(pca,link_action); return(status); } @@ -458,7 +455,7 @@ static void eventCallback(struct event_handler_args arg) epicsPrintf("eventCallback why was arg.usr NULL\n"); return; } - semMutexMustTake(pca->lock); + epicsMutexMustLock(pca->lock); plink = pca->plink; if(!plink) goto done; precord = (dbCommon *)plink->value.pv_link.precord; @@ -507,7 +504,7 @@ static void eventCallback(struct event_handler_args arg) scanOnce(precord); } done: - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); } static void getAttribEventCallback(struct event_handler_args arg) @@ -521,7 +518,7 @@ const struct dbr_ctrl_double *dbr; epicsPrintf("getAttribEventCallback why was arg.usr NULL\n"); return; } - semMutexMustTake(pca->lock); + epicsMutexMustLock(pca->lock); plink = pca->plink; if(!plink) goto done; if(!arg.dbr) { @@ -535,7 +532,7 @@ const struct dbr_ctrl_double *dbr; pcaAttributes->gotData = TRUE; (pcaAttributes->callback)(pcaAttributes->usrPvt); done: - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); } static void accessRightsCallback(struct access_rights_handler_args arg) @@ -548,7 +545,7 @@ static void accessRightsCallback(struct access_rights_handler_args arg) return; } if(ca_state(pca->chid) != cs_conn) return;/*connectionCallback will handle*/ - semMutexMustTake(pca->lock); + epicsMutexMustLock(pca->lock); if(ca_read_access(arg.chid) || ca_write_access(arg.chid)) goto done; plink = pca->plink; if(plink) { @@ -562,7 +559,7 @@ static void accessRightsCallback(struct access_rights_handler_args arg) } } done: - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); } static void connectionCallback(struct connection_handler_args arg) @@ -573,7 +570,7 @@ static void connectionCallback(struct connection_handler_args arg) pca = ca_puser(arg.chid); if(!pca) return; - semMutexMustTake(pca->lock); + epicsMutexMustLock(pca->lock); plink = pca->plink; if(!plink) goto done; if(ca_state(arg.chid) != cs_conn){ @@ -595,7 +592,7 @@ static void connectionCallback(struct connection_handler_args arg) /*Only safe thing is to delete old caLink and allocate a new one*/ pca->plink = 0; plink->value.pv_link.pvt = 0; - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); addAction(pca,CA_DELETE); dbCaAddLink(plink); return; @@ -618,7 +615,7 @@ static void connectionCallback(struct connection_handler_args arg) } if(pca->pcaAttributes) link_action |= CA_GET_ATTRIBUTES; done: - semMutexGive(pca->lock); + epicsMutexUnlock(pca->lock); if(link_action) addAction(pca,link_action); } @@ -636,14 +633,14 @@ void dbCaTask() while(!interruptAccept) threadSleep(.1); /* channel access event loop */ while (TRUE){ - semBinaryMustTake(caWakeupSem); + epicsEventMustWait(caWakeupSem); while(TRUE) { /* process all requests in caList*/ - semMutexMustTake(caListSem); + epicsMutexMustLock(caListSem); if((pca = (caLink *)ellFirst(&caList))){/*Take off list head*/ ellDelete(&caList,&pca->node); link_action = pca->link_action; pca->link_action = 0; - semMutexGive(caListSem); /*Give it back immediately*/ + epicsMutexUnlock(caListSem); /*Give it back immediately*/ if(link_action&CA_DELETE) {/*This must be first*/ if(pca->chid) ca_clear_channel(pca->chid); free(pca->pgetNative); @@ -651,7 +648,7 @@ void dbCaTask() free(pca->pgetString); free(pca->pputString); free(pca->pcaAttributes); - semMutexDestroy(pca->lock); + epicsMutexDestroy(pca->lock); free(pca); continue; /*No other link_action makes sense*/ } @@ -716,7 +713,7 @@ void dbCaTask() ca_message(status)); } } else { /* caList was empty */ - semMutexGive(caListSem); + epicsMutexUnlock(caListSem); break; /*caList is empty*/ } } diff --git a/src/db/dbCaPvt.h b/src/db/dbCaPvt.h index a5b2531bb..ce1cc1898 100644 --- a/src/db/dbCaPvt.h +++ b/src/db/dbCaPvt.h @@ -54,7 +54,7 @@ typedef struct caLink char *pputString; caAttributes *pcaAttributes; long nelements; - semMutexId lock; + epicsMutexId lock; unsigned long nDisconnect; unsigned long nNoWrite; short dbrType; diff --git a/src/db/dbCommon.dbd b/src/db/dbCommon.dbd index 1a1bb9721..57e466f35 100644 --- a/src/db/dbCommon.dbd +++ b/src/db/dbCommon.dbd @@ -70,7 +70,7 @@ prompt("Monitor lock") special(SPC_NOMOD) interest(4) - extra("semMutexId mlok") + extra("epicsMutexId mlok") } field(MLIS,DBF_NOACCESS) { prompt("Monitor List") diff --git a/src/db/dbEvent.c b/src/db/dbEvent.c index ade6cb770..94ff0db35 100644 --- a/src/db/dbEvent.c +++ b/src/db/dbEvent.c @@ -27,7 +27,8 @@ of this distribution. #include "epicsAssert.h" #include "cantProceed.h" #include "dbDefs.h" -#include "osiSem.h" +#include "epicsMutex.h" +#include "epicsEvent.h" #include "osiThread.h" #include "errlog.h" #include "taskwd.h" @@ -73,7 +74,7 @@ struct evSubscrip { struct event_que { /* lock writers to the ring buffer only */ /* readers must never slow up writers */ - semMutexId writelock; + epicsMutexId writelock; db_field_log valque[EVENTQUESIZE]; struct evSubscrip *evque[EVENTQUESIZE]; struct event_que *nextque; /* in case que quota exceeded */ @@ -87,8 +88,8 @@ struct event_que { struct event_user { struct event_que firstque; /* the first event que */ - semBinaryId ppendsem; /* Wait while empty */ - semBinaryId pflush_sem; /* wait for flush */ + epicsEventId ppendsem; /* Wait while empty */ + epicsEventId pflush_sem; /* wait for flush */ OVRFFUNC *overflow_sub; /* called when overflow detect */ void *overflow_arg; /* parameter to above */ @@ -131,16 +132,16 @@ struct event_user { ) #define LOCKEVQUE(EV_QUE)\ -semMutexMustTake((EV_QUE)->writelock); +epicsMutexMustLock((EV_QUE)->writelock); #define UNLOCKEVQUE(EV_QUE)\ -semMutexGive((EV_QUE)->writelock); +epicsMutexUnlock((EV_QUE)->writelock); #define LOCKREC(RECPTR)\ -semMutexMustTake((RECPTR)->mlok); +epicsMutexMustLock((RECPTR)->mlok); #define UNLOCKREC(RECPTR)\ -semMutexGive((RECPTR)->mlok); +epicsMutexUnlock((RECPTR)->mlok); LOCAL void *dbevEventUserFreeList; LOCAL void *dbevEventQueueFreeList; @@ -267,20 +268,20 @@ dbEventCtx epicsShareAPI db_init_events (void) } evUser->firstque.evUser = evUser; - evUser->firstque.writelock = semMutexCreate(); + evUser->firstque.writelock = epicsMutexCreate(); if (!evUser->firstque.writelock) { return NULL; } - evUser->ppendsem = semBinaryCreate(semEmpty); + evUser->ppendsem = epicsEventCreate(epicsEventEmpty); if (!evUser->ppendsem) { - semMutexDestroy (evUser->firstque.writelock); + epicsMutexDestroy (evUser->firstque.writelock); return NULL; } - evUser->pflush_sem = semBinaryCreate(semEmpty); + evUser->pflush_sem = epicsEventCreate(epicsEventEmpty); if (!evUser->pflush_sem) { - semMutexDestroy (evUser->firstque.writelock); - semBinaryDestroy (evUser->ppendsem); + epicsMutexDestroy (evUser->firstque.writelock); + epicsEventDestroy (evUser->ppendsem); return NULL; } evUser->flowCtrlMode = FALSE; @@ -311,7 +312,7 @@ void epicsShareAPI db_close_events (dbEventCtx ctx) evUser->pendexit = TRUE; /* notify the waiting task */ - semBinaryGive(evUser->ppendsem); + epicsEventSignal(evUser->ppendsem); } /* @@ -356,7 +357,7 @@ dbEventSubscription epicsShareAPI db_add_event ( return NULL; } tmp_que->evUser = evUser; - tmp_que->writelock = semMutexCreate(); + tmp_que->writelock = epicsMutexCreate(); if (!tmp_que->writelock) { freeListFree (dbevEventBlockFreeList, pevent); freeListFree (dbevEventQueueFreeList, tmp_que); @@ -485,7 +486,7 @@ void epicsShareAPI db_cancel_event (dbEventSubscription es) pevent->user_sub = NULL; while (pevent->npend || pevent->callBackInProgress) { UNLOCKEVQUE(pevent->ev_que) - semBinaryTakeTimeout(pevent->ev_que->evUser->pflush_sem, 1.0); + epicsEventWaitWithTimeout(pevent->ev_que->evUser->pflush_sem, 1.0); LOCKEVQUE(pevent->ev_que) } UNLOCKEVQUE (pevent->ev_que) @@ -560,7 +561,7 @@ int epicsShareAPI db_post_extra_labor (dbEventCtx ctx) /* notify the event handler of extra labor */ evUser->extra_labor = TRUE; - semBinaryGive(evUser->ppendsem); + epicsEventSignal(evUser->ppendsem); return DB_EVENT_OK; } @@ -683,7 +684,7 @@ LOCAL void db_post_single_event_private (struct evSubscrip *event) /* * notify the event handler */ - semBinaryGive(ev_que->evUser->ppendsem); + epicsEventSignal(ev_que->evUser->ppendsem); } } @@ -857,7 +858,7 @@ LOCAL int event_read (struct event_que *ev_que) * queue */ if (event->user_sub==NULL && event->npend==0u) { - semBinaryGive (ev_que->evUser->pflush_sem); + epicsEventSignal (ev_que->evUser->pflush_sem); } } @@ -882,7 +883,7 @@ LOCAL void event_task (void *pParm) taskwdInsert ( threadGetIdSelf(), NULL, NULL ); do{ - semBinaryMustTake(evUser->ppendsem); + epicsEventMustWait(evUser->ppendsem); /* * check to see if the caller has offloaded @@ -915,7 +916,7 @@ LOCAL void event_task (void *pParm) } }while(!evUser->pendexit); - semMutexDestroy(evUser->firstque.writelock); + epicsMutexDestroy(evUser->firstque.writelock); { struct event_que *nextque; @@ -924,14 +925,14 @@ LOCAL void event_task (void *pParm) while(ev_que){ nextque = ev_que->nextque; - semMutexDestroy(ev_que->writelock); + epicsMutexDestroy(ev_que->writelock); freeListFree(dbevEventQueueFreeList, ev_que); ev_que = nextque; } } - semBinaryDestroy(evUser->ppendsem); - semBinaryDestroy(evUser->pflush_sem); + epicsEventDestroy(evUser->ppendsem); + epicsEventDestroy(evUser->pflush_sem); freeListFree(dbevEventUserFreeList, evUser); @@ -949,14 +950,14 @@ int epicsShareAPI db_start_events ( { struct event_user *evUser = (struct event_user *) ctx; - semMutexMustTake (evUser->firstque.writelock); + epicsMutexMustLock (evUser->firstque.writelock); /* * only one ca_pend_event thread may be * started for each evUser */ if (evUser->taskid) { - semMutexGive (evUser->firstque.writelock); + epicsMutexUnlock (evUser->firstque.writelock); return DB_EVENT_OK; } @@ -970,10 +971,10 @@ int epicsShareAPI db_start_events ( taskname, osiPriority, threadGetStackSize(threadStackMedium), event_task, (void *)evUser); if (!evUser->taskid) { - semMutexGive (evUser->firstque.writelock); + epicsMutexUnlock (evUser->firstque.writelock); return DB_EVENT_ERROR; } - semMutexGive (evUser->firstque.writelock); + epicsMutexUnlock (evUser->firstque.writelock); return DB_EVENT_OK; } @@ -988,7 +989,7 @@ void epicsShareAPI db_event_flow_ctrl_mode_on (dbEventCtx ctx) /* * notify the event handler task */ - semBinaryGive(evUser->ppendsem); + epicsEventSignal(evUser->ppendsem); #ifdef DEBUG printf("fc on %lu\n", tickGet()); #endif @@ -1005,7 +1006,7 @@ void epicsShareAPI db_event_flow_ctrl_mode_off (dbEventCtx ctx) /* * notify the event handler task */ - semBinaryGive (evUser->ppendsem); + epicsEventSignal (evUser->ppendsem); #ifdef DEBUG printf("fc off %lu\n", tickGet()); #endif diff --git a/src/db/dbLock.c b/src/db/dbLock.c index de02deb95..7a83db43d 100644 --- a/src/db/dbLock.c +++ b/src/db/dbLock.c @@ -66,7 +66,7 @@ since this will delay all other threads. #include "dbDefs.h" #include "dbBase.h" -#include "osiSem.h" +#include "epicsMutex.h" #include "tsStamp.h" #include "osiThread.h" #include "cantProceed.h" @@ -88,14 +88,14 @@ since this will delay all other threads. STATIC int lockListInitialized = FALSE; STATIC ELLLIST lockList; -STATIC semMutexId globalLock; +STATIC epicsMutexId globalLock; STATIC unsigned long id = 0; STATIC volatile int changingLockSets = FALSE; typedef struct lockSet { ELLNODE node; ELLLIST recordList; - semMutexId lock; + epicsMutexId lock; threadId thread_id; dbCommon *precord; unsigned long id; @@ -111,7 +111,7 @@ typedef struct lockRecord { STATIC void initLockList(void) { ellInit(&lockList); - globalLock = semMutexMustCreate(); + globalLock = epicsMutexMustCreate(); lockListInitialized = TRUE; } @@ -127,7 +127,7 @@ STATIC lockSet * allocLock(lockRecord *plockRecord) plockSet->id = id; ellAdd(&plockSet->recordList,&plockRecord->node); ellAdd(&lockList,&plockSet->node); - plockSet->lock = semMutexMustCreate(); + plockSet->lock = epicsMutexMustCreate(); return(plockSet); } @@ -141,14 +141,14 @@ STATIC void lockAddRecord(lockSet *plockSet,lockRecord *pnew) void epicsShareAPI dbLockSetGblLock(void) { if(!lockListInitialized) initLockList(); - semMutexMustTake(globalLock); + epicsMutexMustLock(globalLock); changingLockSets = TRUE; } void epicsShareAPI dbLockSetGblUnlock(void) { changingLockSets = FALSE; - semMutexGive(globalLock); + epicsMutexUnlock(globalLock); return; } @@ -156,7 +156,7 @@ void epicsShareAPI dbLockSetRecordLock(dbCommon *precord) { lockRecord *plockRecord = precord->lset; lockSet *plockSet; - semTakeStatus status; + epicsMutexLockStatus status; /*Make sure that dbLockSetGblLock was called*/ if(!changingLockSets) { @@ -168,12 +168,12 @@ void epicsShareAPI dbLockSetRecordLock(dbCommon *precord) if(!plockSet) return; if(plockSet->thread_id==threadGetIdSelf()) return; /*Wait for up to 1 minute*/ - status = semMutexTakeTimeout(plockRecord->plockSet->lock,60.0); - if(status==semTakeOK) { + status = epicsMutexLockWithTimeout(plockRecord->plockSet->lock,60.0); + if(status==epicsMutexLockOK) { plockSet->thread_id = threadGetIdSelf(); plockSet->precord = (void *)precord; /*give it back in case it will not be changed*/ - semMutexGive(plockRecord->plockSet->lock); + epicsMutexUnlock(plockRecord->plockSet->lock); return; } /*Should never reach this point*/ @@ -187,7 +187,7 @@ void epicsShareAPI dbScanLock(dbCommon *precord) { lockRecord *plockRecord; lockSet *plockSet; - semTakeStatus status; + epicsMutexLockStatus status; if(!(plockRecord= precord->lset)) { epicsPrintf("dbScanLock plockRecord is NULL record %s\n", @@ -196,9 +196,9 @@ void epicsShareAPI dbScanLock(dbCommon *precord) } while(TRUE) { while(changingLockSets) threadSleep(.05); - status = semMutexTake(plockRecord->plockSet->lock); - /*semMutexTake fails if semMutexDestroy was called while active*/ - if(status==semTakeOK) break; + status = epicsMutexLock(plockRecord->plockSet->lock); + /*epicsMutexLock fails if epicsMutexDestroy was called while active*/ + if(status==epicsMutexLockOK) break; } plockSet = plockRecord->plockSet; plockSet->thread_id = threadGetIdSelf(); @@ -214,7 +214,7 @@ void epicsShareAPI dbScanUnlock(dbCommon *precord) epicsPrintf("dbScanUnlock plockRecord or plockRecord->plockSet NULL\n"); return; } - semMutexGive(plockRecord->plockSet->lock); + epicsMutexUnlock(plockRecord->plockSet->lock); return; } @@ -320,7 +320,7 @@ void epicsShareAPI dbLockSetMerge(dbCommon *pfirst,dbCommon *psecond) p2lockRecord = (lockRecord *)ellNext(&p2lockRecord->node); } ellConcat(&p1lockSet->recordList,&p2lockSet->recordList); - semMutexDestroy(p2lockSet->lock); + epicsMutexDestroy(p2lockSet->lock); ellDelete(&lockList,&p2lockSet->node); free((void *)p2lockSet); return; @@ -379,7 +379,7 @@ void epicsShareAPI dbLockSetSplit(dbCommon *psource) } if(!plockRecord->plockSet) allocLock(plockRecord); } - semMutexDestroy(plockSet->lock); + epicsMutexDestroy(plockSet->lock); ellDelete(&lockList,&plockSet->node); free((void *)plockSet); free((void *)paprecord); @@ -418,11 +418,10 @@ long epicsShareAPI dblsr(char *recordname,int level) printf("Lock Set %lu %d members", plockSet->id,ellCount(&plockSet->recordList)); - if(semMutexTakeNoWait(plockSet->lock)==semTakeOK) { - semMutexGive(plockSet->lock); + if(epicsMutexTryLock(plockSet->lock)==epicsMutexLockOK) { + epicsMutexUnlock(plockSet->lock); printf(" Not Locked\n"); } else { - TS_STAMP currentTime; printf(" Locked by thread %p",plockSet->thread_id); if(! plockSet->precord || !plockSet->precord->name) printf(" NULL record or record name\n"); diff --git a/src/db/dbNotify.c b/src/db/dbNotify.c index d3ae9702f..b9fe22909 100644 --- a/src/db/dbNotify.c +++ b/src/db/dbNotify.c @@ -38,7 +38,7 @@ #include #include "dbDefs.h" -#include "osiSem.h" +#include "epicsEvent.h" #include "errlog.h" #include "errMdef.h" #include "ellLib.h" @@ -56,9 +56,6 @@ #include "dbAccessDefs.h" #include "recGbl.h" #include "dbNotify.h" -#include "freeList.h" - -static void *putNotifyFreeList; /*NODE structure attached to ppnn field of each record in list*/ typedef struct pnWaitNode { @@ -230,10 +227,11 @@ static void notifyCallback(CALLBACK *pcallback) precord = ppn->paddr->precord; dbScanLock(precord); if(ppn->callbackState==callbackCanceled) { - dbScanUnlock(precord); ppn->restart = FALSE; ppn->callbackState = callbackNotActive; - semBinaryGive((semBinaryId)ppn->waitForCallback); + if(ppn->waitForCallback) + epicsEventSignal((epicsEventId)ppn->waitForCallback); + dbScanUnlock(precord); return; } if(ppn->callbackState==callbackActive) { @@ -244,6 +242,8 @@ static void notifyCallback(CALLBACK *pcallback) dbScanUnlock(precord); (ppn->userCallback)(ppn); } + } else { + dbScanUnlock(precord); } } @@ -261,14 +261,18 @@ void epicsShareAPI dbNotifyCancel(PUTNOTIFY *ppn) dbScanLock(precord); notifyCancel(ppn); if(ppn->callbackState == callbackActive) { - ppn->waitForCallback = (void *)semBinaryMustCreate(semFull); + ppn->waitForCallback = (void *)epicsEventMustCreate(epicsEventEmpty); ppn->callbackState = callbackCanceled; dbScanUnlock(precord); - if(semBinaryTakeTimeout((semBinaryId)ppn->waitForCallback,10.0)!=semTakeOK) { + if(epicsEventWaitWithTimeout( + (epicsEventId)ppn->waitForCallback,10.0)!=epicsEventWaitOK) { errlogPrintf("dbNotifyCancel had semTake timeout\n"); ppn->callbackState = callbackNotActive; } - semBinaryDestroy((semBinaryId)ppn->waitForCallback); + dbScanLock(precord); + epicsEventDestroy((epicsEventId)ppn->waitForCallback); + ppn->waitForCallback = 0; + dbScanUnlock(precord); } else { dbScanUnlock(precord); } diff --git a/src/db/dbScan.c b/src/db/dbScan.c index 7c87eb008..54242d1c9 100644 --- a/src/db/dbScan.c +++ b/src/db/dbScan.c @@ -52,7 +52,8 @@ #include "dbDefs.h" #include "ellLib.h" #include "taskwd.h" -#include "osiSem.h" +#include "epicsMutex.h" +#include "epicsEvent.h" #include "osiInterrupt.h" #include "osiThread.h" #include "tsStamp.h" @@ -76,13 +77,13 @@ /* SCAN ONCE */ int onceQueueSize = 1000; -static semBinaryId onceSem; +static epicsEventId onceSem; static epicsRingPointerId onceQ; static threadId onceTaskId; /*all other scan types */ typedef struct scan_list{ - semMutexId lock; + epicsMutexId lock; ELLLIST list; short modified;/*has list been modified?*/ double rate; @@ -453,7 +454,7 @@ void epicsShareAPI scanOnce(void *precord) }else { newOverflow = TRUE; } - semBinaryGive(onceSem); + epicsEventSignal(onceSem); } static void onceTask(void) @@ -461,8 +462,8 @@ static void onceTask(void) void *precord=NULL; while(TRUE) { - if(semBinaryTake(onceSem)!=semTakeOK) - errlogPrintf("dbScan: semBinaryTake returned error in onceTask"); + if(epicsEventWait(onceSem)!=epicsEventWaitOK) + errlogPrintf("dbScan: epicsEventWait returned error in onceTask"); while(TRUE) { if(!(precord = epicsRingPointerPop(onceQ))) break; dbScanLock(precord); @@ -483,7 +484,7 @@ static void initOnce(void) if((onceQ = epicsRingPointerCreate(onceQueueSize))==NULL){ cantProceed("dbScan: initOnce failed"); } - onceSem=semBinaryMustCreate(semEmpty); + onceSem=epicsEventMustCreate(epicsEventEmpty); onceTaskId = threadCreate("scanOnce",threadPriorityScanHigh, threadGetStackSize(threadStackBig), (THREADFUNC)onceTask,0); @@ -569,21 +570,21 @@ static void printList(scan_list *psl,char *message) { scan_element *pse; - semMutexMustTake(psl->lock); + epicsMutexMustLock(psl->lock); pse = (scan_element *)ellFirst(&psl->list); - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); if(pse==NULL) return; printf("%s\n",message); while(pse!=NULL) { printf(" %-28s\n",pse->precord->name); - semMutexMustTake(psl->lock); + epicsMutexMustLock(psl->lock); if(pse->pscan_list != psl) { - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); printf("Returning because list changed while processing."); return; } pse = (scan_element *)ellNext((void *)pse); - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); } } @@ -595,19 +596,19 @@ static void scanList(scan_list *psl) scan_element *pse,*prev; scan_element *next=0; - semMutexMustTake(psl->lock); + epicsMutexMustLock(psl->lock); psl->modified = FALSE; pse = (scan_element *)ellFirst(&psl->list); prev = NULL; if(pse) next = (scan_element *)ellNext((void *)pse); - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); while(pse) { struct dbCommon *precord = pse->precord; dbScanLock(precord); dbProcess(precord); dbScanUnlock(precord); - semMutexMustTake(psl->lock); + epicsMutexMustLock(psl->lock); if(!psl->modified) { prev = pse; pse = (scan_element *)ellNext((void *)pse); @@ -634,10 +635,10 @@ static void scanList(scan_list *psl) psl->modified = FALSE; } else { /*Too many changes. Just wait till next period*/ - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); return; } - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); } } @@ -665,7 +666,7 @@ static void addToList(struct dbCommon *precord,scan_list *psl) { scan_element *pse,*ptemp; - semMutexMustTake(psl->lock); + epicsMutexMustLock(psl->lock); pse = precord->spvt; if(pse==NULL) { pse = dbCalloc(1,sizeof(scan_element)); @@ -684,7 +685,7 @@ static void addToList(struct dbCommon *precord,scan_list *psl) } if(ptemp==NULL) ellAdd(&psl->list,(void *)pse); psl->modified = TRUE; - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); return; } @@ -692,20 +693,20 @@ static void deleteFromList(struct dbCommon *precord,scan_list *psl) { scan_element *pse; - semMutexMustTake(psl->lock); + epicsMutexMustLock(psl->lock); if(precord->spvt==NULL) { - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); return; } pse = precord->spvt; if(pse==NULL || pse->pscan_list!=psl) { - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); errMessage(-1,"deleteFromList failed"); return; } pse->pscan_list = NULL; ellDelete(&psl->list,(void *)pse); psl->modified = TRUE; - semMutexGive(psl->lock); + epicsMutexUnlock(psl->lock); return; } diff --git a/src/db/dbTest.c b/src/db/dbTest.c index b022c8fde..eea280888 100644 --- a/src/db/dbTest.c +++ b/src/db/dbTest.c @@ -21,7 +21,7 @@ of this distribution. #include "dbDefs.h" #include "errlog.h" #include "ellLib.h" -#include "osiSem.h" +#include "epicsMutex.h" #include "tsStamp.h" #include "ellLib.h" #include "dbBase.h" @@ -383,12 +383,12 @@ long epicsShareAPI dbtr(char *pname) printf("record active\n"); return(1); } - if(semMutexTakeNoWait(precord->mlok)!=semTakeOK) { + if(epicsMutexTryLock(precord->mlok)!=epicsMutexLockOK) { printf("record locked\n"); return(1); } status=dbProcess(precord); - semMutexGive(precord->mlok); + epicsMutexUnlock(precord->mlok); if(status) recGblRecordError(status,precord,"dbtr(dbProcess)"); dbpr(pname,3); diff --git a/src/dbStatic/dbToRecordtypeH.c b/src/dbStatic/dbToRecordtypeH.c index d56fd28a8..d3e1f1d7a 100644 --- a/src/dbStatic/dbToRecordtypeH.c +++ b/src/dbStatic/dbToRecordtypeH.c @@ -125,7 +125,7 @@ int main(int argc,char **argv) exit(-1); } fprintf(outFile,"#include \"ellLib.h\"\n"); - fprintf(outFile,"#include \"osiSem.h\"\n"); + fprintf(outFile,"#include \"epicsMutex.h\"\n"); fprintf(outFile,"#include \"link.h\"\n"); fprintf(outFile,"#include \"tsStamp.h\"\n"); pdbMenu = (dbMenu *)ellFirst(&pdbbase->menuList); diff --git a/src/rsrv/camessage.c b/src/rsrv/camessage.c index e79520c14..77ded0f78 100644 --- a/src/rsrv/camessage.c +++ b/src/rsrv/camessage.c @@ -33,6 +33,8 @@ #include #include "osiSock.h" +#include "epicsEvent.h" +#include "epicsMutex.h" #include "tsStamp.h" #include "errlog.h" #include "db_access_routines.h" @@ -769,7 +771,7 @@ struct client *client size-1); pMalloc[size-1]='\0'; - semMutexMustTake(client->addrqLock); + epicsMutexMustLock(client->addrqLock); pName = client->pHostName; client->pHostName = pMalloc; if(pName){ @@ -784,7 +786,7 @@ struct client *client client->pUserName, client->pHostName); if(status != 0 && status != S_asLib_asNotActive){ - semMutexGive(client->addrqLock); + epicsMutexUnlock(client->addrqLock); log_header ("unable to install new host name into access security", client, mp, 0); SEND_LOCK(client); send_err( @@ -797,7 +799,7 @@ struct client *client } pciu = (struct channel_in_use *) pciu->node.next; } - semMutexGive(client->addrqLock); + epicsMutexUnlock(client->addrqLock); DLOG(2, "CAS: host_name_action for \"%s\"\n", (int) client->pHostName, @@ -856,7 +858,7 @@ struct client *client size-1); pMalloc[size-1]='\0'; - semMutexMustTake(client->addrqLock); + epicsMutexMustLock(client->addrqLock); pName = client->pUserName; client->pUserName = pMalloc; if(pName){ @@ -871,7 +873,7 @@ struct client *client client->pUserName, client->pHostName); if(status != 0 && status != S_asLib_asNotActive){ - semMutexGive(client->addrqLock); + epicsMutexUnlock(client->addrqLock); log_header ("unable to install new user name into access security", client, mp, 0); SEND_LOCK(client); send_err( @@ -884,7 +886,7 @@ struct client *client } pciu = (struct channel_in_use *) pciu->node.next; } - semMutexGive(client->addrqLock); + epicsMutexUnlock(client->addrqLock); DLOG (2, "CAS: client_name_action for \"%s\"\n", (int) client->pUserName, @@ -958,9 +960,9 @@ unsigned cid return NULL; } - semMutexMustTake(client->addrqLock); + epicsMutexMustLock(client->addrqLock); ellAdd(&client->addrq, &pchannel->node); - semMutexGive(client->addrqLock); + epicsMutexUnlock(client->addrqLock); return pchannel; } @@ -1038,7 +1040,7 @@ LOCAL void casAccessRightsCB(ASCLIENTPVT ascpvt, asClientStatus type) /* * Update all event call backs */ - semMutexMustTake(pclient->eventqLock); + epicsMutexMustLock(pclient->eventqLock); for (pevext = (struct event_ext *) ellFirst(&pciu->eventq); pevext; pevext = (struct event_ext *) ellNext(&pevext->node)){ @@ -1055,7 +1057,7 @@ LOCAL void casAccessRightsCB(ASCLIENTPVT ascpvt, asClientStatus type) db_post_single_event(pevext->pdbev); } } - semMutexGive(pclient->eventqLock); + epicsMutexUnlock(pclient->eventqLock); break; @@ -1124,7 +1126,7 @@ struct client *client } } else { - semMutexMustTake(prsrv_cast_client->addrqLock); + epicsMutexMustLock(prsrv_cast_client->addrqLock); /* * clients which dont claim their * channel in use block prior to @@ -1134,7 +1136,7 @@ struct client *client if(!pciu){ errlogPrintf("CAS: client timeout disconnect id=%d\n", mp->m_cid); - semMutexGive(prsrv_cast_client->addrqLock); + epicsMutexUnlock(prsrv_cast_client->addrqLock); SEND_LOCK(client); send_err( mp, @@ -1152,7 +1154,7 @@ struct client *client if (pciu->client!=prsrv_cast_client) { errlogPrintf("CAS: duplicate claim disconnect id=%d\n", mp->m_cid); - semMutexGive(prsrv_cast_client->addrqLock); + epicsMutexUnlock(prsrv_cast_client->addrqLock); SEND_LOCK(client); send_err( mp, @@ -1172,12 +1174,12 @@ struct client *client ellDelete( &prsrv_cast_client->addrq, &pciu->node); - semMutexGive(prsrv_cast_client->addrqLock); + epicsMutexUnlock(prsrv_cast_client->addrqLock); - semMutexMustTake(prsrv_cast_client->addrqLock); + epicsMutexMustLock(prsrv_cast_client->addrqLock); pciu->client = client; ellAdd(&client->addrq, &pciu->node); - semMutexGive(prsrv_cast_client->addrqLock); + epicsMutexUnlock(prsrv_cast_client->addrqLock); } /* @@ -1296,9 +1298,9 @@ LOCAL void write_notify_call_back(PUTNOTIFY *ppn) * the database (or indirectly blocking * one client on another client). */ - semMutexMustTake(pclient->putNotifyLock); + epicsMutexMustLock(pclient->putNotifyLock); ellAdd(&pclient->putNotifyQue, &pciu->pPutNotify->node); - semMutexGive(pclient->putNotifyLock); + epicsMutexUnlock(pclient->putNotifyLock); /* * offload the labor for this to the @@ -1330,9 +1332,9 @@ void write_notify_reply(void *pArg) * the database (or indirectly blocking * one client on another client). */ - semMutexMustTake(pClient->putNotifyLock); + epicsMutexMustLock(pClient->putNotifyLock); ppnb = (RSRVPUTNOTIFY *)ellGet(&pClient->putNotifyQue); - semMutexGive(pClient->putNotifyLock); + epicsMutexUnlock(pClient->putNotifyLock); /* * break to loop exit */ @@ -1384,7 +1386,7 @@ void write_notify_reply(void *pArg) /* * wakeup the TCP thread if it is waiting for a cb to complete */ - semBinaryGive(pClient->blockSem); + epicsEventSignal(pClient->blockSem); } /* @@ -1449,8 +1451,8 @@ struct client *client * serialize concurrent put notifies */ while(pciu->pPutNotify->busy){ - status = semBinaryTakeTimeout(client->blockSem,60.0); - if(status != semTakeOK && pciu->pPutNotify->busy){ + status = epicsEventWaitWithTimeout(client->blockSem,60.0); + if(status != epicsEventWaitOK && pciu->pPutNotify->busy){ log_header("put call back time out", client, mp,0); dbNotifyCancel(&pciu->pPutNotify->dbPutNotify); pciu->pPutNotify->busy = FALSE; @@ -1568,9 +1570,9 @@ LOCAL int event_add_action (caHdr *mp, struct client *client) pevext->size = dbr_size_n(mp->m_dataType, mp->m_count); pevext->mask = pmo->m_info.m_mask; - semMutexMustTake(client->eventqLock); + epicsMutexMustLock(client->eventqLock); ellAdd( &pciu->eventq, &pevext->node); - semMutexGive(client->eventqLock); + epicsMutexUnlock(client->eventqLock); pevext->pdbev = db_add_event (client->evuser, &pciu->addr, read_reply, pevext, pevext->mask); @@ -1660,9 +1662,9 @@ LOCAL int event_add_action (caHdr *mp, struct client *client) } while (TRUE){ - semMutexMustTake(client->eventqLock); + epicsMutexMustLock(client->eventqLock); pevext = (struct event_ext *) ellGet(&pciu->eventq); - semMutexGive(client->eventqLock); + epicsMutexUnlock(client->eventqLock); if(!pevext){ break; @@ -1701,9 +1703,9 @@ LOCAL int event_add_action (caHdr *mp, struct client *client) END_MSG(client); SEND_UNLOCK(client); - semMutexMustTake(client->addrqLock); + epicsMutexMustLock(client->addrqLock); ellDelete(&client->addrq, &pciu->node); - semMutexGive(client->addrqLock); + epicsMutexUnlock(client->addrqLock); /* * remove from access control list @@ -1757,7 +1759,7 @@ LOCAL int event_cancel_reply (caHdr *mp, struct client *client) * search events on this channel for a match * (there are usually very few monitors per channel) */ - semMutexMustTake(client->eventqLock); + epicsMutexMustLock(client->eventqLock); for (pevext = (struct event_ext *) ellFirst(&pciu->eventq); pevext; pevext = (struct event_ext *) ellNext(&pevext->node)){ @@ -1766,7 +1768,7 @@ LOCAL int event_cancel_reply (caHdr *mp, struct client *client) break; } } - semMutexGive(client->eventqLock); + epicsMutexUnlock(client->eventqLock); /* * Not Found- return an exception event diff --git a/src/rsrv/caservertask.c b/src/rsrv/caservertask.c index 8128c8607..7731236c2 100644 --- a/src/rsrv/caservertask.c +++ b/src/rsrv/caservertask.c @@ -37,6 +37,8 @@ #include #include "osiSock.h" +#include "epicsEvent.h" +#include "epicsMutex.h" #include "tsStamp.h" #include "errlog.h" #include "taskwd.h" @@ -75,7 +77,7 @@ struct client *create_base_client () * memset(client, 0, sizeof(*client)); */ - client->blockSem = semBinaryCreate(semEmpty); + client->blockSem = epicsEventCreate(epicsEventEmpty); if(!client->blockSem){ freeListFree(rsrvClientFreeList, client); return NULL; @@ -86,7 +88,7 @@ struct client *create_base_client () */ client->pUserName = malloc(1); if(!client->pUserName){ - semBinaryDestroy(client->blockSem); + epicsEventDestroy(client->blockSem); freeListFree(rsrvClientFreeList, client); return NULL; } @@ -97,7 +99,7 @@ struct client *create_base_client () */ client->pHostName = malloc(1); if(!client->pHostName){ - semBinaryDestroy(client->blockSem); + epicsEventDestroy(client->blockSem); free(client->pUserName); freeListFree(rsrvClientFreeList, client); return NULL; @@ -122,10 +124,10 @@ struct client *create_base_client () client->send.maxstk = MAX_UDP_SEND; - client->lock = semMutexMustCreate(); - client->putNotifyLock = semMutexMustCreate(); - client->addrqLock = semMutexMustCreate(); - client->eventqLock = semMutexMustCreate(); + client->lock = epicsMutexMustCreate(); + client->putNotifyLock = epicsMutexMustCreate(); + client->addrqLock = epicsMutexMustCreate(); + client->eventqLock = epicsMutexMustCreate(); client->recv.maxstk = MAX_UDP_RECV; return client; @@ -450,7 +452,7 @@ epicsShareFunc int epicsShareAPI rsrv_init (void) { threadId tid; - clientQlock = semMutexMustCreate(); + clientQlock = epicsMutexMustCreate(); ellInit (&clientQ); freeListInitPvt (&rsrvClientFreeList, sizeof(struct client), 8); @@ -526,7 +528,7 @@ LOCAL void log_one_client (struct client *client, unsigned level) bytes_reserved = 0; bytes_reserved += sizeof(struct client); - semMutexMustTake(client->addrqLock); + epicsMutexMustLock(client->addrqLock); pciu = (struct channel_in_use *) client->addrq.node.next; while (pciu){ bytes_reserved += sizeof(struct channel_in_use); @@ -537,11 +539,11 @@ LOCAL void log_one_client (struct client *client, unsigned level) } pciu = (struct channel_in_use *) ellNext(&pciu->node); } - semMutexGive(client->addrqLock); + epicsMutexUnlock(client->addrqLock); printf( "\t%ld bytes allocated\n", bytes_reserved); - semMutexMustTake(client->addrqLock); + epicsMutexMustLock(client->addrqLock); pciu = (struct channel_in_use *) client->addrq.node.next; i=0; while (pciu){ @@ -555,21 +557,21 @@ LOCAL void log_one_client (struct client *client, unsigned level) printf("\n"); } } - semMutexGive(client->addrqLock); + epicsMutexUnlock(client->addrqLock); printf("\n"); } if (level >= 3u) { printf( "\tSend Lock\n"); - semMutexShow(client->lock,1); + epicsMutexShow(client->lock,1); printf( "\tPut Notify Lock\n"); - semMutexShow (client->putNotifyLock,1); + epicsMutexShow (client->putNotifyLock,1); printf( "\tAddress Queue Lock\n"); - semMutexShow (client->addrqLock,1); + epicsMutexShow (client->addrqLock,1); printf( "\tEvent Queue Lock\n"); - semMutexShow (client->eventqLock,1); + epicsMutexShow (client->eventqLock,1); printf( "\tBlock Semaphore\n"); - semBinaryShow (client->blockSem,1); + epicsEventShow (client->blockSem,1); } } @@ -671,9 +673,9 @@ void destroy_client (struct client *client) } while(TRUE){ - semMutexMustTake (client->addrqLock); + epicsMutexMustLock (client->addrqLock); pciu = (struct channel_in_use *) ellGet(&client->addrq); - semMutexGive (client->addrqLock); + epicsMutexUnlock (client->addrqLock); if (!pciu) { break; } @@ -691,10 +693,10 @@ void destroy_client (struct client *client) /* * AS state change could be using this list */ - semMutexMustTake (client->eventqLock); + epicsMutexMustLock (client->eventqLock); pevext = (struct event_ext *) ellGet(&pciu->eventq); - semMutexGive (client->eventqLock); + epicsMutexUnlock (client->eventqLock); if(!pevext){ break; } @@ -745,15 +747,15 @@ void destroy_client (struct client *client) } } - semMutexDestroy (client->eventqLock); + epicsMutexDestroy (client->eventqLock); - semMutexDestroy (client->addrqLock); + epicsMutexDestroy (client->addrqLock); - semMutexDestroy (client->putNotifyLock); + epicsMutexDestroy (client->putNotifyLock); - semMutexDestroy (client->lock); + epicsMutexDestroy (client->lock); - semBinaryDestroy (client->blockSem); + epicsEventDestroy (client->blockSem); if (client->pUserName) { free (client->pUserName); diff --git a/src/rsrv/cast_server.c b/src/rsrv/cast_server.c index 4693c726b..dcecfbb7d 100644 --- a/src/rsrv/cast_server.c +++ b/src/rsrv/cast_server.c @@ -50,6 +50,7 @@ #include #include "osiSock.h" +#include "epicsMutex.h" #include "dbDefs.h" #include "errlog.h" #include "taskwd.h" @@ -77,7 +78,7 @@ LOCAL void clean_addrq() tsStampGetCurrent(¤t); - semMutexMustTake(prsrv_cast_client->addrqLock); + epicsMutexMustLock(prsrv_cast_client->addrqLock); pnextciu = (struct channel_in_use *) prsrv_cast_client->addrq.node.next; @@ -101,7 +102,7 @@ LOCAL void clean_addrq() if(delay>maxdelay) maxdelay = delay; } } - semMutexGive(prsrv_cast_client->addrqLock); + epicsMutexUnlock(prsrv_cast_client->addrqLock); # ifdef DEBUG if(ndelete){ diff --git a/src/rsrv/server.h b/src/rsrv/server.h index 4265b0d02..b114f9c77 100644 --- a/src/rsrv/server.h +++ b/src/rsrv/server.h @@ -35,6 +35,8 @@ #endif /* ifdef epicsExportSharedSymbols */ #include "osiThread.h" +#include "epicsMutex.h" +#include "epicsEvent.h" #include "bucketLib.h" #include "asLib.h" #include "dbAddr.h" @@ -92,10 +94,10 @@ struct client { ELLNODE node; struct message_buffer send; struct message_buffer recv; - semMutexId lock; - semMutexId putNotifyLock; - semMutexId addrqLock; - semMutexId eventqLock; + epicsMutexId lock; + epicsMutexId putNotifyLock; + epicsMutexId addrqLock; + epicsMutexId eventqLock; ELLLIST addrq; ELLLIST putNotifyQue; struct sockaddr_in addr; @@ -104,7 +106,7 @@ struct client { void *evuser; char *pUserName; char *pHostName; - semBinaryId blockSem; /* used whenever the client blocks */ + epicsEventId blockSem; /* used whenever the client blocks */ SOCKET sock; int proto; threadId tid; @@ -185,7 +187,7 @@ GLBLTYPE SOCKET IOC_cast_sock; GLBLTYPE unsigned short ca_server_port; GLBLTYPE ELLLIST clientQ; /* locked by clientQlock */ GLBLTYPE ELLLIST beaconAddrList; -GLBLTYPE semMutexId clientQlock; +GLBLTYPE epicsMutexId clientQlock; GLBLTYPE struct client *prsrv_cast_client; GLBLTYPE BUCKET *pCaBucket; GLBLTYPE void *rsrvClientFreeList; @@ -196,8 +198,8 @@ GLBLTYPE void *rsrvEventFreeList; GLBLTYPE int casSufficentSpaceInPool; -#define SEND_LOCK(CLIENT) semMutexMustTake((CLIENT)->lock) -#define SEND_UNLOCK(CLIENT) semMutexGive((CLIENT)->lock) +#define SEND_LOCK(CLIENT) epicsMutexMustLock((CLIENT)->lock) +#define SEND_UNLOCK(CLIENT) epicsMutexUnlock((CLIENT)->lock) #define EXTMSGPTR(CLIENT)\ ((caHdr *) &(CLIENT)->send.buf[(CLIENT)->send.stk]) @@ -213,8 +215,8 @@ GLBLTYPE int casSufficentSpaceInPool; EXTMSGPTR(CLIENT)->m_postsize = CA_MESSAGE_ALIGN(EXTMSGPTR(CLIENT)->m_postsize),\ (CLIENT)->send.stk += sizeof(caHdr) + EXTMSGPTR(CLIENT)->m_postsize -#define LOCK_CLIENTQ semMutexMustTake (clientQlock); -#define UNLOCK_CLIENTQ semMutexGive (clientQlock); +#define LOCK_CLIENTQ epicsMutexMustLock (clientQlock); +#define UNLOCK_CLIENTQ epicsMutexUnlock (clientQlock); void camsgtask (struct client *client); void cas_send_msg (struct client *pclient, int lock_needed);