From 20196ff5029c1188b885a89d080bf27cfad6fe8a Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Tue, 4 Jan 2000 20:26:19 +0000 Subject: [PATCH] replace osiClock calls with tsStamp calls --- src/db/dbAccess.c | 6 ++--- src/db/dbAccess.h | 2 +- src/db/dbBkpt.c | 17 ++++++++------ src/db/dbBkpt.h | 3 ++- src/db/dbCa.c | 1 + src/db/dbCa.h | 2 +- src/db/dbEvent.c | 2 -- src/db/dbLock.c | 13 ++++++----- src/db/dbScan.c | 56 +++++++++++++++------------------------------- src/db/db_access.h | 2 +- src/db/initHooks.h | 20 ----------------- src/db/iocInit.c | 3 --- src/db/recGbl.c | 6 ++--- 13 files changed, 47 insertions(+), 86 deletions(-) diff --git a/src/db/dbAccess.c b/src/db/dbAccess.c index 7436816ee..5a91f4312 100644 --- a/src/db/dbAccess.c +++ b/src/db/dbAccess.c @@ -806,7 +806,7 @@ long dbPutLinkValue(struct link *plink,short dbrType, status=dbPut(paddr,dbrType,pbuffer,nRequest); if(ppv_link->pvlMask&pvlOptMS) - recGblSetSevr(pdest,LINK_ALARM,psource->sevr); + recGblSetSevr(pdest,LINK_ALARM,psource->nsev); if(status) return(status); if((paddr->pfield==(void *)&pdest->proc) || (ppv_link->pvlMask&pvlOptPP && pdest->scan==0)) { @@ -1133,10 +1133,10 @@ long dbPut(DBADDR *paddr,short dbrType,const void *pbuffer,long nRequest) if(special==SPC_ATTRIBUTE) return(S_db_noMod); if(dbrType==DBR_PUT_ACKT && field_type<=DBF_DEVICE) { - status=putAckt(paddr,pbuffer,(long)1,(long)1,(long)0); + status=putAckt(paddr,(unsigned short*)pbuffer,1l,1l,0l); return(status); } else if(dbrType==DBR_PUT_ACKS && field_type<=DBF_DEVICE) { - status=putAcks(paddr,pbuffer,(long)1,(long)1,(long)0); + status=putAcks(paddr,(unsigned short*)pbuffer,1l,1l,0l); return(status); } else if( INVALID_DB_REQ(dbrType) || (field_type>DBF_DEVICE)) { sprintf(message,"dbPut - database request type is %d",dbrType); diff --git a/src/db/dbAccess.h b/src/db/dbAccess.h index 949530c2a..fea01f78c 100644 --- a/src/db/dbAccess.h +++ b/src/db/dbAccess.h @@ -35,7 +35,7 @@ of this distribution. #include "link.h" #include "dbCommon.h" #include "dbLock.h" -#include "osiTime.h" +#include "tsStamp.h" #include "callback.h" #include "ellLib.h" #include "caeventmask.h" diff --git a/src/db/dbBkpt.c b/src/db/dbBkpt.c index 63976f2e9..ede8aa64b 100644 --- a/src/db/dbBkpt.c +++ b/src/db/dbBkpt.c @@ -14,6 +14,9 @@ of this distribution. /* Modification Log: * ----------------- * $Log$ + * Revision 1.11 1999/12/14 22:01:33 mrk + * changes for osiSem changes + * * Revision 1.10 1999/09/13 18:26:17 mrk * changes for 3.14 * @@ -65,9 +68,9 @@ of this distribution. #include #include "dbDefs.h" -#include "osiClock.h" #include "osiThread.h" #include "osiSem.h" +#include "tsStamp.h" #include "ellLib.h" #include "errlog.h" #include "alarm.h" @@ -725,7 +728,7 @@ int dbBkpt(struct dbCommon *precord) pqe->entrypoint = precord; pqe->count = 1; - pqe->time = clockGetCurrentTick(); + tsStampGetCurrent(&pqe->time); pqe->sched = 0; #ifdef BKPT_DIAG @@ -891,11 +894,11 @@ long dbstat() struct LS_LIST *pnode; struct BP_LIST *pbl; struct EP_LIST *pqe; - unsigned long time; + TS_STAMP time; semMutexMustTake(bkpt_stack_sem); - time = clockGetCurrentTick(); + tsStampGetCurrent(&time); /* * Traverse list, reporting stopped records @@ -910,10 +913,10 @@ long dbstat() /* for each entrypoint detected, print out entrypoint statistics */ pqe = (struct EP_LIST *) ellFirst(&pnode->ep_queue); while (pqe != NULL) { - if (time - pqe->time) { + double diff = tsStampDiffInSeconds(&time,&pqe->time); + if (diff) { printf(" Entrypoint: %-28.28s #C: %5.5lu C/S: %7.1f\n", - pqe->entrypoint->name, pqe->count, - clockGetRate() * pqe->count/((double)(time-pqe->time))); + pqe->entrypoint->name, pqe->count,diff); } pqe = (struct EP_LIST *) ellNext((ELLNODE *)pqe); } diff --git a/src/db/dbBkpt.h b/src/db/dbBkpt.h index ea72fdb4c..9c754bf96 100644 --- a/src/db/dbBkpt.h +++ b/src/db/dbBkpt.h @@ -34,6 +34,7 @@ #include #include +#include #include /* Needs to be put into dbTest.h ! */ long dbpr(char *name, int level); @@ -58,7 +59,7 @@ struct EP_LIST { ELLNODE *prev_list; struct dbCommon *entrypoint; /* pointer to entry point in lockset */ unsigned long count; /* number of times record processed */ - unsigned long time; /* time record first logged */ + TS_STAMP time; /* time record first logged */ char sched; /* schedule record for next dbContTask() pass */ }; diff --git a/src/db/dbCa.c b/src/db/dbCa.c index 9fc5dab30..9f8b3d8bc 100644 --- a/src/db/dbCa.c +++ b/src/db/dbCa.c @@ -33,6 +33,7 @@ of this distribution. #include "dbDefs.h" #include "osiSem.h" #include "osiThread.h" +#include "tsStamp.h" #include "errlog.h" #include "cadef.h" #include "caerr.h" diff --git a/src/db/dbCa.h b/src/db/dbCa.h index abcdc1db8..68e75f5e0 100644 --- a/src/db/dbCa.h +++ b/src/db/dbCa.h @@ -1,4 +1,4 @@ -/* dbCa.h.c */ +/* dbCa.h */ /***************************************************************** COPYRIGHT NOTIFICATION ***************************************************************** diff --git a/src/db/dbEvent.c b/src/db/dbEvent.c index 6a8c9ba58..7997e9586 100644 --- a/src/db/dbEvent.c +++ b/src/db/dbEvent.c @@ -66,11 +66,9 @@ of this distribution. #include "dbDefs.h" #include "osiSem.h" #include "osiThread.h" -#include "osiClock.h" #include "errlog.h" #include "taskwd.h" #include "freeList.h" -#include "tsDefs.h" #include "dbCommon.h" #include "dbAccess.h" #include "dbEvent.h" diff --git a/src/db/dbLock.c b/src/db/dbLock.c index edd2a345c..d2cf230ad 100644 --- a/src/db/dbLock.c +++ b/src/db/dbLock.c @@ -67,7 +67,7 @@ since this will delay all other threads. #include "dbDefs.h" #include "dbBase.h" #include "osiSem.h" -#include "osiClock.h" +#include "tsStamp.h" #include "osiThread.h" #include "cantProceed.h" #include "ellLib.h" @@ -93,7 +93,7 @@ typedef struct lockSet { ELLNODE node; ELLLIST recordList; semId lock; - unsigned long start_time; + TS_STAMP start_time; threadId thread_id; dbCommon *precord; unsigned long id; @@ -170,7 +170,7 @@ void dbLockSetRecordLock(dbCommon *precord) /*Wait for up to 1 minute*/ status = semMutexTakeTimeout(plockRecord->plockSet->lock,60.0); if(status==semTakeOK) { - plockSet->start_time = clockGetCurrentTick(); + tsStampGetCurrent(&plockSet->start_time); plockSet->thread_id = threadGetIdSelf(); plockSet->precord = (void *)precord; /*give it back in case it will not be changed*/ @@ -202,7 +202,7 @@ void dbScanLock(dbCommon *precord) if(status==semTakeOK) break; } plockSet = plockRecord->plockSet; - plockSet->start_time = clockGetCurrentTick(); + tsStampGetCurrent(&plockSet->start_time); plockSet->thread_id = threadGetIdSelf(); plockSet->precord = (void *)precord; return; @@ -426,8 +426,9 @@ long dblsr(char *recordname,int level) semMutexGive(plockSet->lock); printf(" Not Locked\n"); } else { - lockSeconds = plockSet->start_time; - lockSeconds = (clockGetCurrentTick() - lockSeconds) / clockGetRate(); + TS_STAMP currentTime; + lockSeconds = tsStampDiffInSeconds( + ¤tTime,&plockSet->start_time); printf(" Locked %f seconds", lockSeconds); printf(" thread %p",plockSet->thread_id); if(! plockSet->precord || !plockSet->precord->name) diff --git a/src/db/dbScan.c b/src/db/dbScan.c index 67dd1b0ca..bb85c684b 100644 --- a/src/db/dbScan.c +++ b/src/db/dbScan.c @@ -54,7 +54,7 @@ #include "osiSem.h" #include "osiInterrupt.h" #include "osiThread.h" -#include "osiClock.h" +#include "tsStamp.h" #include "cantProceed.h" #include "osiRing.h" #include "epicsPrint.h" @@ -84,7 +84,7 @@ typedef struct scan_list{ semId lock; ELLLIST list; short modified;/*has list been modified?*/ - long ticks; /*ticks per period for periodic*/ + double rate; }scan_list; /*scan_elements are allocated and the address stored in dbCommon.spvt*/ typedef struct scan_element{ @@ -93,7 +93,6 @@ typedef struct scan_element{ struct dbCommon *precord; }scan_element; -int volatile scanRestart=FALSE; static char *priorityName[NUM_CALLBACK_PRIORITIES] = { "Low","Medium","High"}; @@ -116,7 +115,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 void **periodicTaskId; /*array of pointers after allocation*/ +static threadId *periodicTaskId; /*array of thread ids*/ /* Private routines */ static void onceTask(void); @@ -124,7 +123,6 @@ static void initOnce(void); static void periodicTask(void *arg); static void initPeriodic(void); static void spawnPeriodic(int ind); -static void wdPeriodic(long ind); static void initEvent(void); static void eventCallback(CALLBACK *pcallback); static void ioeventCallback(CALLBACK *pcallback); @@ -316,16 +314,13 @@ int scanppl(double rate) /*print periodic list*/ { scan_list *psl; char message[80]; - double period; int i; for (i=0; iticks; - period /= clockGetRate(); - if(rate>0.0 && (fabs(rate - period) >.05)) continue; - sprintf(message,"Scan Period= %f seconds ",period); + if(rate>0.0 && (fabs(rate - psl->rate) >.05)) continue; + sprintf(message,"Scan Period= %f seconds ",psl->rate); printList(psl,message); } return(0); @@ -501,22 +496,19 @@ static void periodicTask(void *arg) { scan_list *psl = (scan_list *)arg; - unsigned long start_time,end_time,diff; - double delay; + TS_STAMP start_time,end_time; + double diff; + double delay; - start_time = clockGetCurrentTick(); + tsStampGetCurrent(&start_time); while(TRUE) { if(interruptAccept)scanList(psl); - end_time = clockGetCurrentTick(); - if(end_time>=start_time) { - diff = end_time - start_time; - } else { - diff = 1 + end_time + (ULONG_MAX - start_time); - } - delay = psl->ticks - diff; - delay = (delay<=0.0) ? .1 : delay/clockGetRate(); + tsStampGetCurrent(&end_time); + diff = tsStampDiffInSeconds(&end_time,&start_time); + delay = psl->rate - diff; + delay = (delay<=0.0) ? .1 : delay; threadSleep(delay); - start_time = clockGetCurrentTick(); + tsStampGetCurrent(&start_time); } } @@ -542,7 +534,7 @@ static void initPeriodic() psl->lock = semMutexMustCreate(); ellInit(&psl->list); sscanf(pmenu->papChoiceValue[i+SCAN_1ST_PERIODIC],"%f",&temp); - psl->ticks = temp * clockGetRate(); + psl->rate = temp; } } @@ -552,26 +544,14 @@ static void spawnPeriodic(int ind) char taskName[20]; psl = papPeriodic[ind]; - sprintf(taskName,"scan%ld",psl->ticks); + sprintf(taskName,"scan%f",psl->rate); periodicTaskId[ind] = threadCreate( taskName, threadPriorityScanLow + ind, threadGetStackSize(threadStackBig), - periodicTask, + (THREADFUNC)periodicTask, (void *)psl); - taskwdInsert(periodicTaskId[ind],wdPeriodic,(void *)(long)ind); -} - -static void wdPeriodic(long ind) -{ - scan_list *psl; - - if(!scanRestart)return; - psl = papPeriodic[ind]; - taskwdRemove(periodicTaskId[ind]); - /*Unlock so that task can be resumed*/ - semMutexGive(psl->lock); - spawnPeriodic(ind); + taskwdInsert(periodicTaskId[ind],NULL,0L); } static void ioeventCallback(CALLBACK *pcallback) diff --git a/src/db/db_access.h b/src/db/db_access.h index 14e8cf9f4..756086db9 100644 --- a/src/db/db_access.h +++ b/src/db/db_access.h @@ -96,7 +96,7 @@ extern "C" { #include #include "epicsTypes.h" -#include "osiTime.h" +#include "tsStamp.h" #include "callback.h" #include "ellLib.h" #include "dbAddr.h" diff --git a/src/db/initHooks.h b/src/db/initHooks.h index d273e5218..4592801e0 100644 --- a/src/db/initHooks.h +++ b/src/db/initHooks.h @@ -44,7 +44,6 @@ typedef enum { initHookAfterInitDrvSup, initHookAfterInitRecSup, initHookAfterInitDevSup, - initHookAfterClockInit, initHookAfterInitDatabase, initHookAfterFinishDevSup, initHookAfterScanInit, @@ -71,23 +70,4 @@ void initHooks(); } #endif -/*FOLLOWING IS OBSOLETE*/ -/*The following are for compatibility with old initHooks.c functions*/ -#define INITHOOKatBeginning initHookAtBeginning -#define INITHOOKafterGetResources initHookAfterGetResources -#define INITHOOKafterLogInit initHookAfterLogInit -#define INITHOOKafterCallbackInit initHookAfterCallbackInit -#define INITHOOKafterCaLinkInit initHookAfterCaLinkInit -#define INITHOOKafterInitDrvSup initHookAfterInitDrvSup -#define INITHOOKafterInitRecSup initHookAfterInitRecSup -#define INITHOOKafterInitDevSup initHookAfterInitDevSup -#define INITHOOKafterTS_init initHookAfterTS_init -#define INITHOOKafterInitDatabase initHookAfterInitDatabase -#define INITHOOKafterFinishDevSup initHookAfterFinishDevSup -#define INITHOOKafterScanInit initHookAfterScanInit -#define INITHOOKafterInterruptAccept initHookAfterInterruptAccept -#define INITHOOKafterInitialProcess initHookAfterInitialProcess -#define INITHOOKatEnd initHookAtEnd -/*END OF OBSOLETE DEFINITIONS*/ - #endif /*INCinitHooksh*/ diff --git a/src/db/iocInit.c b/src/db/iocInit.c index 72273a537..55b1a88d2 100644 --- a/src/db/iocInit.c +++ b/src/db/iocInit.c @@ -53,7 +53,6 @@ of this distribution. #include "dbDefs.h" #include "osiThread.h" -#include "osiClock.h" #include "osiSem.h" #include "epicsPrint.h" #include "ellLib.h" @@ -77,7 +76,6 @@ of this distribution. #include "dbStaticLib.h" #include "initHooks.h" #include "asLib.h" -#include "logClient.h" LOCAL int initialized=FALSE; @@ -123,7 +121,6 @@ int iocInit() initDrvSup(); initHooks(initHookAfterInitDrvSup); initRecSup(); initHooks(initHookAfterInitRecSup); initDevSup(); initHooks(initHookAfterInitDevSup); - clockInit(); initHooks(initHookAfterClockInit); initDatabase(); dbLockInitRecords(pdbbase); diff --git a/src/db/recGbl.c b/src/db/recGbl.c index 63da2e0ab..d2ba1a28e 100644 --- a/src/db/recGbl.c +++ b/src/db/recGbl.c @@ -48,7 +48,7 @@ #include #include "dbDefs.h" -#include "osiClock.h" +#include "tsStamp.h" #include "epicsPrint.h" #include "dbBase.h" #include "dbAccess.h" @@ -315,10 +315,10 @@ void recGblGetTimeStamp(void* prec) if(pr->tsel.type!=CONSTANT) { dbGetLink(&(pr->tsel), DBR_SHORT,&(pr->tse),0,0); - status = clockGetEventTime((int)pr->tse,&pr->time); + status = tsStampGetEvent((int)pr->tse,&pr->time); } else - status = clockGetEventTime((int)pr->tse,&pr->time); + status = tsStampGetEvent((int)pr->tse,&pr->time); if(status) errlogPrintf("%s recGblGetTimeStamp failed\n",pr->name); }