replace osiClock calls with tsStamp calls

This commit is contained in:
Marty Kraimer
2000-01-04 20:26:19 +00:00
parent 1c7e8ed138
commit 20196ff502
13 changed files with 47 additions and 86 deletions

View File

@@ -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);

View File

@@ -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"

View File

@@ -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 <string.h>
#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);
}

View File

@@ -34,6 +34,7 @@
#include <ellLib.h>
#include <osiSem.h>
#include <tsStamp.h>
#include <osiThread.h>
/* 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 */
};

View File

@@ -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"

View File

@@ -1,4 +1,4 @@
/* dbCa.h.c */
/* dbCa.h */
/*****************************************************************
COPYRIGHT NOTIFICATION
*****************************************************************

View File

@@ -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"

View File

@@ -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(
&currentTime,&plockSet->start_time);
printf(" Locked %f seconds", lockSeconds);
printf(" thread %p",plockSet->thread_id);
if(! plockSet->precord || !plockSet->precord->name)

View File

@@ -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; i<nPeriodic; i++) {
psl = papPeriodic[i];
if(psl==NULL) continue;
period = psl->ticks;
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)

View File

@@ -96,7 +96,7 @@ extern "C" {
#include <stddef.h>
#include "epicsTypes.h"
#include "osiTime.h"
#include "tsStamp.h"
#include "callback.h"
#include "ellLib.h"
#include "dbAddr.h"

View File

@@ -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*/

View File

@@ -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);

View File

@@ -48,7 +48,7 @@
#include <limits.h>
#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);
}