add timerTest
This commit is contained in:
@@ -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
|
||||
|
||||
87
src/libCom/test/timerTest.c
Normal file
87
src/libCom/test/timerTest.c
Normal file
@@ -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 <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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; i<ntimers ; i++) {
|
||||
timer[i] = calloc(1,sizeof(myPvt));
|
||||
timer[i]->timer = 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;
|
||||
}
|
||||
24
src/libCom/test/timerTestMain.c
Normal file
24
src/libCom/test/timerTestMain.c
Normal file
@@ -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 <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void timerTest(void);
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
timerTest();
|
||||
printf("main terminating\n");
|
||||
return(0);
|
||||
}
|
||||
Reference in New Issue
Block a user