replace most internal getCurrent() -> getMonotonic()

every place where a time delta is computed, and then some.
This commit is contained in:
Michael Davidsaver
2018-12-23 20:48:58 -08:00
parent 8b9ad212c4
commit 4f2228fb1d
21 changed files with 57 additions and 57 deletions

View File

@@ -83,7 +83,7 @@ int CASG::block (
return ECA_TIMEOUT;
}
cur_time = epicsTime::getCurrent ();
cur_time = epicsTime::getMonotonic ();
this->client.flush ( guard );
@@ -121,7 +121,7 @@ int CASG::block (
/*
* force a time update
*/
cur_time = epicsTime::getCurrent ();
cur_time = epicsTime::getMonotonic ();
delay = cur_time - beg_time;
}

View File

@@ -481,7 +481,7 @@ int ca_client_context::pendIO ( const double & timeout )
}
int status = ECA_NORMAL;
epicsTime beg_time = epicsTime::getCurrent ();
epicsTime beg_time = epicsTime::getMonotonic ();
double remaining = timeout;
epicsGuard < epicsMutex > guard ( this->mutex );
@@ -499,7 +499,7 @@ int ca_client_context::pendIO ( const double & timeout )
this->blockForEventAndEnableCallbacks ( this->ioDone, remaining );
}
double delay = epicsTime::getCurrent () - beg_time;
double delay = epicsTime::getMonotonic () - beg_time;
if ( delay < timeout ) {
remaining = timeout - delay;
}
@@ -528,7 +528,7 @@ int ca_client_context::pendEvent ( const double & timeout )
return ECA_EVDISALLOW;
}
epicsTime current = epicsTime::getCurrent ();
epicsTime current = epicsTime::getMonotonic ();
{
epicsGuard < epicsMutex > guard ( this->mutex );
@@ -569,7 +569,7 @@ int ca_client_context::pendEvent ( const double & timeout )
this->noWakeupSincePend = true;
}
double elapsed = epicsTime::getCurrent() - current;
double elapsed = epicsTime::getMonotonic() - current;
double delay;
if ( timeout > elapsed ) {

View File

@@ -130,7 +130,7 @@ cac::cac (
epicsMutex & callbackControlIn,
cacContextNotify & notifyIn ) :
_refLocalHostName ( localHostNameCache.getReference () ),
programBeginTime ( epicsTime::getCurrent() ),
programBeginTime ( epicsTime::getMonotonic() ),
connTMO ( CA_CONN_VERIFY_PERIOD ),
mutex ( mutualExclusionIn ),
cbMutex ( callbackControlIn ),

View File

@@ -59,7 +59,7 @@ int main ( int argc, char ** argv )
epicsMutex mutex;
epicsGuard < epicsMutex > guard ( mutex );
bheFreeStoreMgr bheFreeList;
epicsTime programBeginTime = epicsTime::getCurrent ();
epicsTime programBeginTime = epicsTime::getMonotonic ();
bool validCommandLine = false;
unsigned interest = 0u;
SOCKET sock;
@@ -244,7 +244,7 @@ int main ( int argc, char ** argv )
ca_uint32_t beaconNumber = ntohl ( pCurMsg->m_cid );
unsigned protocolRevision = ntohs ( pCurMsg->m_dataType );
epicsTime currentTime = epicsTime::getCurrent();
epicsTime currentTime = epicsTime::getMonotonic();
/*
* look for it in the hash table

View File

@@ -43,7 +43,7 @@ searchTimer::searchTimer (
const unsigned indexIn,
epicsMutex & mutexIn,
bool boostPossibleIn ) :
timeAtLastSend ( epicsTime::getCurrent () ),
timeAtLastSend ( epicsTime::getMonotonic () ),
timer ( queueIn.createTimer () ),
iiu ( iiuIn ),
mutex ( mutexIn ),

View File

@@ -476,7 +476,7 @@ void tcpRecvThread::run ()
statusWireIO stat;
pComBuf->fillFromWire ( this->iiu, stat );
epicsTime currentTime = epicsTime::getCurrent ();
epicsTime currentTime = epicsTime::getMonotonic ();
{
epicsGuard < epicsMutex > guard ( this->iiu.mutex );
@@ -1669,7 +1669,7 @@ bool tcpiiu::sendThreadFlush ( epicsGuard < epicsMutex > & guard )
if ( this->sendQue.occupiedBytes() > 0 ) {
while ( comBuf * pBuf = this->sendQue.popNextComBufToSend () ) {
epicsTime current = epicsTime::getCurrent ();
epicsTime current = epicsTime::getMonotonic ();
unsigned bytesToBeSent = pBuf->occupiedBytes ();
bool success = false;

View File

@@ -435,7 +435,7 @@ void udpRecvThread::run ()
}
else if ( status > 0 ) {
this->iiu.postMsg ( src, this->iiu.recvBuf,
(arrayElementCount) status, epicsTime::getCurrent() );
(arrayElementCount) status, epicsTime::getMonotonic() );
}
} while ( ! this->iiu.shutdownCmd );

View File

@@ -144,12 +144,12 @@ void dbPutNotifyBlocker::initiatePutNotify (
break;
}
if ( beginTimeInit ) {
if ( epicsTime::getCurrent () - begin > 30.0 ) {
if ( epicsTime::getMonotonic () - begin > 30.0 ) {
throw cacChannel::requestTimedOut ();
}
}
else {
begin = epicsTime::getCurrent ();
begin = epicsTime::getMonotonic ();
beginTimeInit = true;
}
{

View File

@@ -97,7 +97,7 @@ epicsShareFunc void fdManager::process (double delay)
// more than once here so that fd activity get serviced
// in a reasonable length of time.
//
double minDelay = this->pTimerQueue->process(epicsTime::getCurrent());
double minDelay = this->pTimerQueue->process(epicsTime::getMonotonic());
if ( minDelay >= delay ) {
minDelay = delay;
@@ -121,7 +121,7 @@ epicsShareFunc void fdManager::process (double delay)
fd_set * pExceptSet = & this->fdSetsPtr[fdrException];
int status = select (this->maxFD, pReadSet, pWriteSet, pExceptSet, &tv);
this->pTimerQueue->process(epicsTime::getCurrent());
this->pTimerQueue->process(epicsTime::getMonotonic());
if ( status > 0 ) {
@@ -204,7 +204,7 @@ epicsShareFunc void fdManager::process (double delay)
* of select()
*/
epicsThreadSleep(minDelay);
this->pTimerQueue->process(epicsTime::getCurrent());
this->pTimerQueue->process(epicsTime::getMonotonic());
}
this->processInProg = false;
return;

View File

@@ -143,7 +143,7 @@ bool epicsThread::exitWait ( const double delay ) throw ()
}
return true;
}
epicsTime exitWaitBegin = epicsTime::getCurrent ();
epicsTime exitWaitBegin = epicsTime::getMonotonic ();
double exitWaitElapsed = 0.0;
epicsGuard < epicsMutex > guard ( this->mutex );
this->cancel = true;
@@ -151,7 +151,7 @@ bool epicsThread::exitWait ( const double delay ) throw ()
epicsGuardRelease < epicsMutex > unguard ( guard );
this->event.signal ();
this->exitEvent.wait ( delay - exitWaitElapsed );
epicsTime current = epicsTime::getCurrent ();
epicsTime current = epicsTime::getMonotonic ();
exitWaitElapsed = current - exitWaitBegin;
}
}

View File

@@ -173,7 +173,7 @@ extern "C" double epicsShareAPI
epicsTimerQueuePassiveProcess ( epicsTimerQueuePassiveId pQueue )
{
try {
return pQueue->process ( epicsTime::getCurrent() );
return pQueue->process ( epicsTime::getMonotonic() );
}
catch ( ... ) {
return 1.0;

View File

@@ -118,7 +118,7 @@ inline double epicsTimer::getExpireDelay ()
{
epicsTimer::expireInfo info = this->getExpireInfo ();
if ( info.active ) {
double delay = info.expireTime - epicsTime::getCurrent ();
double delay = info.expireTime - epicsTime::getMonotonic ();
if ( delay < 0.0 ) {
delay = 0.0;
}

View File

@@ -54,7 +54,7 @@ void timer::destroy ()
void timer::start ( epicsTimerNotify & notify, double delaySeconds )
{
this->start ( notify, epicsTime::getCurrent () + delaySeconds );
this->start ( notify, epicsTime::getMonotonic () + delaySeconds );
}
void timer::start ( epicsTimerNotify & notify, const epicsTime & expire )
@@ -129,7 +129,7 @@ void timer::privateStart ( epicsTimerNotify & notify, const epicsTime & expire )
debugPrintf ( ("Start of \"%s\" with delay %f at %p preempting %u\n",
typeid ( this->notify ).name (),
expire - epicsTime::getCurrent (),
expire - epicsTime::getMonotonic (),
this, preemptCount ) );
}
@@ -190,7 +190,7 @@ void timer::show ( unsigned int level ) const
double delay;
if ( this->curState == statePending || this->curState == stateActive ) {
try {
delay = this->exp - epicsTime::getCurrent();
delay = this->exp - epicsTime::getMonotonic();
}
catch ( ... ) {
delay = - DBL_MAX;

View File

@@ -29,7 +29,7 @@ timerQueue::timerQueue ( epicsTimerQueueNotify & notifyIn ) :
pExpireTmr ( 0 ),
processThread ( 0 ),
exceptMsgTimeStamp (
epicsTime :: getCurrent () - exceptMsgMinPeriod ),
epicsTime :: getMonotonic () - exceptMsgMinPeriod ),
cancelPending ( false )
{
}
@@ -48,7 +48,7 @@ void timerQueue ::
char date[64];
double delay;
try {
epicsTime cur = epicsTime :: getCurrent ();
epicsTime cur = epicsTime :: getMonotonic ();
delay = cur - this->exceptMsgTimeStamp;
cur.strftime ( date, sizeof ( date ),
"%a %b %d %Y %H:%M:%S.%f" );

View File

@@ -72,7 +72,7 @@ void timerQueueActive :: _printLastChanceExceptionMessage (
{
char date[64];
try {
epicsTime cur = epicsTime :: getCurrent ();
epicsTime cur = epicsTime :: getMonotonic ();
cur.strftime ( date, sizeof ( date ), "%a %b %d %Y %H:%M:%S.%f");
}
catch ( ... ) {
@@ -90,7 +90,7 @@ void timerQueueActive :: run ()
this->exitFlag = false;
while ( ! this->terminateFlag ) {
try {
double delay = this->queue.process ( epicsTime::getCurrent() );
double delay = this->queue.process ( epicsTime::getMonotonic() );
debugPrintf ( ( "timer thread sleeping for %g sec (max)\n", delay ) );
this->rescheduleEvent.wait ( delay );
}

View File

@@ -147,11 +147,11 @@ void Perf :: measure (double srcD, float srcF, int prec)
std::memset(buf, 0, sizeof(buf));
epicsTime beg = epicsTime :: getCurrent ();
epicsTime beg = epicsTime :: getMonotonic ();
for ( unsigned i = 0; i < nIterations; i++ ) {
c->target (srcD, srcF, buf, sizeof(buf) - 1, prec);
}
epicsTime end = epicsTime :: getCurrent ();
epicsTime end = epicsTime :: getMonotonic ();
double elapsed = end - beg;
elapsed /= nIterations * nUnrolled;

View File

@@ -394,12 +394,12 @@ static const unsigned N = 10000;
void recursiveOwnershipRetPerformance ()
{
RefCtr refCtr;
epicsTime begin = epicsTime::getCurrent ();
epicsTime begin = epicsTime::getMonotonic ();
for ( size_t i = 0; i < N; i++ ) {
Ownership ownership ( refCtr );
recurRetOwner1000 ( ownership );
}
double delay = epicsTime::getCurrent () - begin;
double delay = epicsTime::getMonotonic () - begin;
delay /= N * 1000u; // convert to delay per call
delay *= 1e6; // convert to micro seconds
testDiag ( "retOwnership() takes %f microseconds", delay );
@@ -408,13 +408,13 @@ void recursiveOwnershipRetPerformance ()
void ownershipPassRefPerformance ()
{
RefCtr refCtr;
epicsTime begin = epicsTime::getCurrent ();
epicsTime begin = epicsTime::getMonotonic ();
for ( size_t i = 0; i < N; i++ ) {
Ownership ownershipSrc ( refCtr );
Ownership ownershipDest;
passRefOwnership1000 ( ownershipSrc, ownershipDest );
}
double delay = epicsTime::getCurrent () - begin;
double delay = epicsTime::getMonotonic () - begin;
delay /= N * 1000u; // convert to delay per call
delay *= 1e6; // convert to micro seconds
testDiag ( "passRefOwnership() takes %f microseconds", delay );
@@ -456,7 +456,7 @@ void Ten < T > :: diagnostic ( double delay )
template < class T >
void measurePerformance ()
{
epicsTime begin = epicsTime::getCurrent ();
epicsTime begin = epicsTime::getMonotonic ();
T target;
for ( size_t i = 0; i < N; i++ ) {
target.run ();
@@ -470,7 +470,7 @@ void measurePerformance ()
target.run ();
target.run ();
}
double delay = epicsTime::getCurrent () - begin;
double delay = epicsTime::getMonotonic () - begin;
delay /= ( N * 10u ); // convert to delay per call
target.diagnostic ( delay );
}

View File

@@ -156,9 +156,9 @@ static void eventWakeupTest(void)
static double eventWaitMeasureDelayError( const epicsEventId &id, const double & delay )
{
epicsTime beg = epicsTime::getCurrent();
epicsTime beg = epicsTime::getMonotonic();
epicsEventWaitWithTimeout ( id, delay );
epicsTime end = epicsTime::getCurrent();
epicsTime end = epicsTime::getMonotonic();
double meas = end - beg;
double error = fabs ( delay - meas );
testDiag("epicsEventWaitWithTimeout(%.6f) delay error %.6f sec",

View File

@@ -168,32 +168,32 @@ void epicsMutexPerformance ()
unsigned i;
// test a single lock pair
epicsTime begin = epicsTime::getCurrent ();
epicsTime begin = epicsTime::getMonotonic ();
static const unsigned N = 1000;
for ( i = 0; i < N; i++ ) {
tenLockPairsSquared ( mutex );
}
double delay = epicsTime::getCurrent () - begin;
double delay = epicsTime::getMonotonic () - begin;
delay /= N * 100u; // convert to delay per lock pair
delay *= 1e6; // convert to micro seconds
testDiag("lock()*1/unlock()*1 takes %f microseconds", delay);
// test a two times recursive lock pair
begin = epicsTime::getCurrent ();
begin = epicsTime::getMonotonic ();
for ( i = 0; i < N; i++ ) {
tenDoubleRecursiveLockPairsSquared ( mutex );
}
delay = epicsTime::getCurrent () - begin;
delay = epicsTime::getMonotonic () - begin;
delay /= N * 100u; // convert to delay per lock pair
delay *= 1e6; // convert to micro seconds
testDiag("lock()*2/unlock()*2 takes %f microseconds", delay);
// test a four times recursive lock pair
begin = epicsTime::getCurrent ();
begin = epicsTime::getMonotonic ();
for ( i = 0; i < N; i++ ) {
tenQuadRecursiveLockPairsSquared ( mutex );
}
delay = epicsTime::getCurrent () - begin;
delay = epicsTime::getMonotonic () - begin;
delay /= N * 100u; // convert to delay per lock pair
delay *= 1e6; // convert to micro seconds
testDiag("lock()*4/unlock()*4 takes %f microseconds", delay);

View File

@@ -55,9 +55,9 @@ static void epicsThreadPriorityTest()
static double threadSleepMeasureDelayError ( const double & delay )
{
epicsTime beg = epicsTime::getCurrent();
epicsTime beg = epicsTime::getMonotonic();
epicsThreadSleep ( delay );
epicsTime end = epicsTime::getCurrent();
epicsTime end = epicsTime::getMonotonic();
double meas = end - beg;
double error = fabs ( delay - meas );
return error;
@@ -76,10 +76,10 @@ static double measureSleepQuantum (
double interval = rand ();
interval /= RAND_MAX;
interval *= testInterval;
epicsTime start = epicsTime::getCurrent ();
epicsTime start = epicsTime::getMonotonic ();
epicsTime current = start;
while ( current - start < interval ) {
current = epicsTime::getCurrent ();
current = epicsTime::getMonotonic ();
}
errorSum += threadSleepMeasureDelayError ( testInterval );
if ( i % ( iterations / 10 ) == 0 ) {
@@ -150,7 +150,7 @@ static void epicsThreadGetIdSelfPerfTest ()
{
static const unsigned N = 10000;
static const double microSecPerSec = 1e6;
epicsTime begin = epicsTime::getCurrent ();
epicsTime begin = epicsTime::getMonotonic ();
for ( unsigned i = 0u; i < N; i++ ) {
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
@@ -164,7 +164,7 @@ static void epicsThreadGetIdSelfPerfTest ()
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
};
epicsTime end = epicsTime::getCurrent ();
epicsTime end = epicsTime::getMonotonic ();
printf ( "It takes %f micro sec to call epicsThreadGetIdSelf ()\n",
microSecPerSec * ( end - begin ) / (10 * N) );
}
@@ -204,12 +204,12 @@ static void timeEpicsThreadPrivateGet ()
{
priv.set ( 0 );
epicsTime begin = epicsTime::getCurrent ();
epicsTime begin = epicsTime::getMonotonic ();
static const unsigned N = 1000u;
for ( unsigned i = 0u; i < N; i++ ) {
callItTenTimesSquared ();
}
double delay = epicsTime::getCurrent() - begin;
double delay = epicsTime::getMonotonic() - begin;
delay /= N * 100u; // convert to sec per call
delay *= 1e6; // convert to micro sec
printf("epicsThreadPrivateGet() takes %f microseconds\n", delay);

View File

@@ -156,7 +156,7 @@ void testAccuracy ()
expireCount = nTimers;
for ( i = 0u; i < nTimers; i++ ) {
epicsTime cur = epicsTime::getCurrent ();
epicsTime cur = epicsTime::getMonotonic ();
pTimers[i]->setBegin ( cur );
pTimers[i]->start ( cur + pTimers[i]->delay () );
}
@@ -253,7 +253,7 @@ void testCancel ()
testDiag ( "cancelCount = %u", cancelVerify::cancelCount );
testDiag ( "starting %d timers", nTimers );
epicsTime exp = epicsTime::getCurrent () + 4.0;
epicsTime exp = epicsTime::getMonotonic () + 4.0;
for ( i = 0u; i < nTimers; i++ ) {
pTimers[i]->start ( exp );
}
@@ -339,7 +339,7 @@ void testExpireDestroy ()
testOk1 ( expireDestroyVerify::destroyCount == 0 );
testDiag ( "starting %d timers", nTimers );
epicsTime cur = epicsTime::getCurrent ();
epicsTime cur = epicsTime::getMonotonic ();
for ( i = 0u; i < nTimers; i++ ) {
pTimers[i]->start ( cur );
}
@@ -432,7 +432,7 @@ void testPeriodic ()
testOk1 ( timerCount == nTimers );
testDiag ( "starting %d timers", nTimers );
epicsTime cur = epicsTime::getCurrent ();
epicsTime cur = epicsTime::getMonotonic ();
for ( i = 0u; i < nTimers; i++ ) {
pTimers[i]->start ( cur );
}