Exemplo n.º 1
0
void Scheduler::waitUntilQueued(ThreadInfo* th) {
    uint64_t startNs = getNs();
    uint32_t sleepUs = 1;
    while(!IsSleepingInFutex(th->linuxPid, th->linuxTid, (uintptr_t)&schedLock)) {
        TrueSleep(sleepUs++); // linear backoff, start small but avoid overwhelming the OS with short sleeps
        uint64_t curNs = getNs();
        if (curNs - startNs > (2L<<31L) /* ~2s */) {
            warn("waitUntilQueued for pid %d tid %d timed out", getPid(th->gid), getTid(th->gid));
            return;
        }
    }
}
    virtual void getAllParameters(std::vector<double>& v) const
    {
        int nPar = 6;

        if(varyNEff_)
            ++nPar;
        if(varySumMNu_)
            ++nPar;

        v.resize(nPar);

        std::vector<double>::iterator it = v.begin();
        *(it++) = getOmBH2();
        *(it++) = getOmCH2();
        *(it++) = getH();
        *(it++) = getTau();
        *(it++) = getNs();
        *(it++) = std::log(getAs()*1e10);

        if(varyNEff_)
            *(it++) = nEff_;

        if(varySumMNu_)
            *(it++) = sumMNu_;

        check(it == v.end(), "");
    }
Exemplo n.º 3
0
// Internal, called with schedLock held
void Scheduler::futexWakeJoin(ThreadInfo* th) {  // may release schedLock
    assert(th->futexJoin.action == FJA_WAKE);

    uint32_t maxWakes = th->futexJoin.maxWakes;
    uint32_t wokenUp = th->futexJoin.wokenUp;

    // Adjust allowance
    assert(maxWakes <= maxAllowedFutexWakeups);
    assert(wokenUp <= maxWakes);
    maxAllowedFutexWakeups -= (maxWakes - wokenUp);

    assert(unmatchedFutexWakeups <= maxAllowedFutexWakeups); // should panic...

    DEBUG_FUTEX("Futex wake matching %d %d", unmatchedFutexWakeups, maxAllowedFutexWakeups);

    while (true) {
        futex_unlock(&schedLock);
        uint64_t startNs = getNs();
        uint32_t iters = 0;
        while (wokenUp > unmatchedFutexWakeups) {
            TrueSleep(10*(1 + iters));  // linear backoff, start small but avoid overwhelming the OS with short sleeps
            iters++;
            uint64_t curNs = getNs();
            if (curNs - startNs > (2L<<31L) /* ~2s */) {
                futex_lock(&schedLock);
                warn("Futex wake matching failed (%d/%d) (external/ff waiters?)", unmatchedFutexWakeups, wokenUp);
                unmatchedFutexWakeups = 0;
                maxAllowedFutexWakeups -= wokenUp;
                return;
            }
        }

        futex_lock(&schedLock);

        // Recheck after acquire, may have concurrent wakes here
        if (wokenUp <= unmatchedFutexWakeups) {
            unmatchedFutexWakeups -= wokenUp;
            maxAllowedFutexWakeups -= wokenUp;
            break;
        }
    }

    DEBUG_FUTEX("Finished futex wake matching");
}
 virtual void getAllParameters(std::vector<double>& v) const
 { 
     v.resize(8);
     v[0] = getOmBH2();
     v[1] = getOmCH2();
     v[2] = getH();
     v[3] = getTau();
     v[4] = getNs();
     v[5] = std::log(getAs() * 1e10);
     v[6] = getNEff();
     v[7] = getSumMNu();
 }
Exemplo n.º 5
0
 boost::time_max_t getMs() const
 {
   const boost::time_max_t ns = getNs();
   // ceil/floor away from zero
   if (ns >= 0)
   {
     // return ceiling of positive numbers
     return (ns + 999999) / 1000000;
   }
   else
   {
     // return floor of negative numbers
     return (ns - 999999) / 1000000;
   }
 }
Exemplo n.º 6
0
const char* ClassNs::getName() const {
   return isNs() ? getNs()->name.c_str() : getClass()->name.c_str();
}
Second HighRezTimer::getCurrentTime()
{
	// Second(ticks) / 1000.0
	return static_cast<Second>(getNs()) * 1e-9;
}