From d85256a196798d12ffd29d91cb7aafbc7d740c26 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Fri, 11 Feb 2000 17:01:42 +0000 Subject: [PATCH] add timerTest --- src/libCom/test/Makefile | 4 ++ src/libCom/test/timerTest.c | 87 +++++++++++++++++++++++++++++++++ src/libCom/test/timerTestMain.c | 24 +++++++++ 3 files changed, 115 insertions(+) create mode 100644 src/libCom/test/timerTest.c create mode 100644 src/libCom/test/timerTestMain.c diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index 2a47ca389..47b3bbf7f 100644 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -4,6 +4,10 @@ include $(TOP)/configure/CONFIG PROD_LIBS += Com +timerTestHost_SRCS += timerTestMain.c timerTest.c +PROD += timerTestHost +OBJS_IOC += timerTest + semBinaryTestHost_SRCS += semBinaryTestMain.c semBinaryTest.c PROD += semBinaryTestHost OBJS_IOC += semBinaryTest diff --git a/src/libCom/test/timerTest.c b/src/libCom/test/timerTest.c new file mode 100644 index 000000000..0f9138426 --- /dev/null +++ b/src/libCom/test/timerTest.c @@ -0,0 +1,87 @@ +/* timerTest.c */ + +/* Author: Marty Kraimer Date: 26JAN2000 */ + +/********************COPYRIGHT NOTIFICATION********************************** +This software was developed under a United States Government license +described on the COPYRIGHT_UniversityOfChicago file included as part +of this distribution. +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "osiThread.h" +#include "osiTimer.h" +#include "errlog.h" +#include "taskwd.h" +#include "tsStamp.h" + +static void expire(void *pPrivate); +static void destroy(void *pPrivate); +static int again(void *pPrivate); +static double delay(void *pPrivate); +static void show(void *pPrivate, unsigned level); +static osiTimerJumpTable jumpTable = { expire,destroy,again,delay,show}; +static osiTimerQueueId timerQueue; + +typedef struct myPvt { + osiTimerId timer; + double requestedDiff; + TS_STAMP start; +}myPvt; + + +#define ntimers 3 + +void timerTest(void) +{ + myPvt *timer[ntimers]; + TS_STAMP start; + int i; + + timerQueue = osiTimerQueueCreate(threadPriorityLow); + for(i=0; itimer = osiTimerCreate(&jumpTable,(void *)timer[i]); + tsStampGetCurrent(&start); + timer[i]->start = start; + timer[i]->requestedDiff = (double)i; + osiTimerArm(timer[i]->timer,timerQueue,(double)i); + } + threadSleep((double)(ntimers + 2)); + printf("timerTest returning\n"); +} + +void expire(void *pPrivate) +{ + myPvt *pmyPvt = (myPvt *)pPrivate; + TS_STAMP end; + double diff; + + tsStampGetCurrent(&end); + diff = tsStampDiffInSeconds(&end,&pmyPvt->start); + printf("myCallback requestedDiff %f diff %f\n",pmyPvt->requestedDiff,diff); +} + +void destroy(void *pPrivate) +{ + return; +} + +int again(void *pPrivate) +{ + return(0); +} + +double delay(void *pPrivate) +{ + return(0.0); +} +void show(void *pPrivate, unsigned level) +{ + return; +} diff --git a/src/libCom/test/timerTestMain.c b/src/libCom/test/timerTestMain.c new file mode 100644 index 000000000..cb8bd1162 --- /dev/null +++ b/src/libCom/test/timerTestMain.c @@ -0,0 +1,24 @@ +/* timerTestMain.c */ +/* Author: Marty Kraimer Date: 26JAN2000 */ + +/********************COPYRIGHT NOTIFICATION********************************** +This software was developed under a United States Government license +described on the COPYRIGHT_UniversityOfChicago file included as part +of this distribution. +****************************************************************************/ + +#include +#include +#include +#include +#include + + +void timerTest(void); + +int main(int argc,char *argv[]) +{ + timerTest(); + printf("main terminating\n"); + return(0); +}