diff options
Diffstat (limited to 'tools/gator/daemon/UserSpaceSource.cpp')
-rw-r--r-- | tools/gator/daemon/UserSpaceSource.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/tools/gator/daemon/UserSpaceSource.cpp b/tools/gator/daemon/UserSpaceSource.cpp index 4a9b22f4b555..f58f828e6e2e 100644 --- a/tools/gator/daemon/UserSpaceSource.cpp +++ b/tools/gator/daemon/UserSpaceSource.cpp @@ -1,13 +1,16 @@ /** - * Copyright (C) ARM Limited 2010-2014. All rights reserved. + * Copyright (C) ARM Limited 2010-2015. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#define __STDC_FORMAT_MACROS + #include "UserSpaceSource.h" +#include <inttypes.h> #include <sys/prctl.h> #include <unistd.h> @@ -35,45 +38,45 @@ void UserSpaceSource::run() { gSessionData->usDrivers[i]->start(); } - int64_t monotonic_started = 0; - while (monotonic_started <= 0) { + int64_t monotonicStarted = 0; + while (monotonicStarted <= 0 && gSessionData->mSessionIsActive) { usleep(10); if (gSessionData->perf.isSetup()) { - monotonic_started = gSessionData->mMonotonicStarted; + monotonicStarted = gSessionData->mMonotonicStarted; } else { - if (DriverSource::readInt64Driver("/dev/gator/started", &monotonic_started) == -1) { - logg->logError(__FILE__, __LINE__, "Error reading gator driver start time"); + if (DriverSource::readInt64Driver("/dev/gator/started", &monotonicStarted) == -1) { + logg->logError("Error reading gator driver start time"); handleException(); } - gSessionData->mMonotonicStarted = monotonic_started; + gSessionData->mMonotonicStarted = monotonicStarted; } } - uint64_t next_time = 0; + uint64_t nextTime = 0; while (gSessionData->mSessionIsActive) { - const uint64_t curr_time = getTime() - monotonic_started; + const uint64_t currTime = getTime() - monotonicStarted; // Sample ten times a second ignoring gSessionData->mSampleRate - next_time += NS_PER_S/10;//gSessionData->mSampleRate; - if (next_time < curr_time) { - logg->logMessage("Too slow, curr_time: %lli next_time: %lli", curr_time, next_time); - next_time = curr_time; + nextTime += NS_PER_S/10;//gSessionData->mSampleRate; + if (nextTime < currTime) { + logg->logMessage("Too slow, currTime: %" PRIi64 " nextTime: %" PRIi64, currTime, nextTime); + nextTime = currTime; } - if (mBuffer.eventHeader(curr_time)) { + if (mBuffer.eventHeader(currTime)) { for (int i = 0; i < ARRAY_LENGTH(gSessionData->usDrivers); ++i) { gSessionData->usDrivers[i]->read(&mBuffer); } // Only check after writing all counters so that time and corresponding counters appear in the same frame - mBuffer.check(curr_time); + mBuffer.check(currTime); } - if (mBuffer.bytesAvailable() <= 0) { + if (gSessionData->mOneShot && gSessionData->mSessionIsActive && (mBuffer.bytesAvailable() <= 0)) { logg->logMessage("One shot (counters)"); child->endSession(); } - usleep((next_time - curr_time)/NS_PER_US); + usleep((nextTime - currTime)/NS_PER_US); } mBuffer.setDone(); |