added timeout and sleep delay tests

This commit is contained in:
Jeff Hill
2001-05-04 21:41:23 +00:00
parent 9549c0dc00
commit 01311de271
2 changed files with 37 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
/* epicsThreadTest.cpp */
/* Author: Marty Kraimer Date: 26JAN2000 */
/* Author: Marty Kraimer Date: 26JAN2000 */
/* sleep accuracy tests by Jeff Hill */
/********************COPYRIGHT NOTIFICATION**********************************
This software was developed under a United States Government license
@@ -15,8 +16,10 @@ of this distribution.
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <math.h>
#include "epicsThread.h"
#include "epicsTime.h"
#include "errlog.h"
static epicsThreadPrivate<int> privateKey;
@@ -52,6 +55,18 @@ void myThread::run()
errlogPrintf("threadFunc %d stopping argvalue %p\n",myPrivate,argvalue);
}
static void threadSleepTest()
{
for ( unsigned i = 0u; i < 20; i++ ) {
epicsTime beg = epicsTime::getCurrent();
double delay = ldexp ( 1.0 , -i );
epicsThreadSleep ( delay );
epicsTime end = epicsTime::getCurrent();
printf ( "epicsThreadSleep ( %g ) finished after %g sec\n",
delay, end - beg );
}
}
extern "C" void threadTest(int ntasks,int verbose)
{
myThread **papmyThread;
@@ -60,6 +75,8 @@ extern "C" void threadTest(int ntasks,int verbose)
int startPriority,minPriority,maxPriority;
int errVerboseSave = errVerbose;
threadSleepTest();
errVerbose = verbose;
errlogInit(4096);
papmyThread = (myThread **)calloc(ntasks,sizeof(myThread *));