Ejemplo n.º 1
0
//生成堆栈地址, 不输出地址对应文件行, 如需要使用 ./control core 命令可对 core.log 进行解释生成代码行记录
bool CSignalMgr::GenCoreLog(int signo)
{
    if ( core_log_name.empty() )
        return false;

    int64 tid = (int64)syscall(SYS_gettid);

    //char* sed_string = "sed '1,8d' | sed '$d' | sed '$d' | sed '$d' | sed '$d' | sed '$d'";
    const char* sed_string = "sed '1,8d'";

    local_execute( "date > %s.date", core_log_name.c_str() );
    local_execute( "pstack %lu | %s > %s.stack",
        tid,
        sed_string,
        core_log_name.c_str() );
    local_execute( "cat %s %s.date %s.stack > %s.out",
        core_log_name.c_str(),
        core_log_name.c_str(),
        core_log_name.c_str(),
        core_log_name.c_str() );
    local_execute( "rm -f %s %s.date %s.stack",
        core_log_name.c_str(),
        core_log_name.c_str(),
        core_log_name.c_str() );
    local_execute( "mv %s.out %s", core_log_name.c_str(), core_log_name.c_str() );

    return true;
}
Ejemplo n.º 2
0
void SchedulerNode::local_deplete_queue() {
  TaskId task_id;
  while (generic_tasks_.unique_pull(task_id)) {
    DLOG << id() << ": Executing own task.";
    local_execute(task_id);
  }
}
Ejemplo n.º 3
0
bool SchedulerNode::local_steal_and_execute(NodeId from) {
  TaskId task_id;
  if (scheduler_->node(from).generic_tasks_.shared_pull(task_id)) {
    DLOG << id() << ": Stole task from " << from;
    local_execute(task_id);
    return true;
  }
  return false;
}
Ejemplo n.º 4
0
void SchedulerNode::run_tasks_loop() {
  CHECK(scheduler_);
  CHECK(this_id_ != INVALID_NODE);
  auto num_nodes = scheduler_->num_nodes();
  uint32_t num_empty_runs = 0;
  auto steal_id = steal_from_.load();
  DLOG << id() << ": Node running. Depleting initial queue...";
  local_deplete_queue();
  available_.store(true);
  while (!stop_flag_.load()) {
    do {
      steal_id = (steal_id + 1) % num_nodes;
    } while (steal_id == this_id_);

    if (local_steal_and_execute(steal_id)) {
      if (!available_.exchange(false, std::memory_order_acq_rel)) {
        auto new_steal_id = steal_from_.load(std::memory_order_acquire);
        if (steal_id != new_steal_id && local_steal_and_execute(new_steal_id)) {
          steal_id = new_steal_id;
          DLOG << id() << ": Dealing with interleaved wakeup from "
                    << steal_id;
        }
      }
      num_empty_runs = 0;
    } else if ((num_empty_runs += 1) == num_nodes) {
      DLOG << id() << ": Enough empty runs, sleeping...";
      wakeup_.wait();
      steal_id = steal_from_.load(std::memory_order_acquire);
      DLOG << id() << ": Woken up by " << steal_id << ". Doing task..";
      local_steal_and_execute(steal_id);
      DLOG << id() << ": Going back to stealing.";
      num_empty_runs = 0;
    } else {
      continue;
    }

    TaskId pulled_id;
    while (generic_tasks_.unique_pull(pulled_id)) local_execute(pulled_id);
    available_.store(true, std::memory_order_release);
  }
}