Exemplo n.º 1
0
void Game::run()
{
	if(running) return;

	currentGame = this;

	prepareRun();
}
Exemplo n.º 2
0
int Oomd::run() {
  if (!prepareRun()) {
    return 1;
  }

  uint64_t ticks = 0;
  uint64_t detector_ticks = 0;
  uint64_t killer_ticks = 0;

  XLOG(INFO) << "Running oomd";
  while (true) {
    if (need_tunables_reload) {
      tunables_->loadOverrides();
      tunables_->dump();
      need_tunables_reload = false;
    }
    updateTunables();

    const auto before = std::chrono::steady_clock::now();

    if (verbose_ && ++ticks % verbose_ticks_ == 0) {
      std::ostringstream oss;
      oss << "detectorticks=" << detector_ticks
          << " killticks=" << killer_ticks;
      OOMD_LOG(oss.str(), "oomd heartbeat");
    }

    for (auto& cgroup : cgroups_) {
      updateContext(cgroup->detector->getCgroupPath(), cgroup->context);

      ++detector_ticks;
      if (cgroup->detector->isOOM(cgroup->context)) {
        ++killer_ticks;
        if (cgroup->killer->tryToKillSomething(cgroup->context)) {
          std::this_thread::sleep_for(post_kill_delay_ / 2);
          cgroup->detector->postKill(cgroup->context);
          std::this_thread::sleep_for(post_kill_delay_ / 2);

          // Only kill 1 process system-wide per Tunable::INTERVAL.
          // We do this because oomd examines the system as a whole,
          // as opposed to an isolated per-cgroup manner
          break;
        }
      }
    }

    // Rotate cgroups_ so we have round robin for fairness
    std::rotate(cgroups_.begin(), cgroups_.begin() + 1, cgroups_.end());

    // We may have slept already, so recalculate
    const auto after = std::chrono::steady_clock::now();
    auto to_sleep = interval_ - (after - before);
    if (to_sleep < std::chrono::seconds(0)) {
      to_sleep = std::chrono::seconds(0);
    }

    std::this_thread::sleep_for(to_sleep);
  }

  return 0;
}
Exemplo n.º 3
0
/*---------------------------------------------------------------------*//**
	メインスクリプトの実行準備
**//*---------------------------------------------------------------------*/
bool Es::prepareRun(EsContext* ctx, EsExtParam paramRun)
{
	return prepareRun(ctx, 0L, 0, 0L, paramRun);
}