Profiler::~Profiler() { SET_AFFINITY(0, sizeof(cpu_set_t), &m_prev_mask); endAllFrames(); for (Frame *p = m_frame_free_list; p;) { Frame *cur = p; p = p->m_parent; free(cur); } }
Profiler::~Profiler() { if (m_has_affinity) { SET_AFFINITY(0, sizeof(cpu_set_t), &m_prev_mask); } endAllFrames(); for (Frame *p = m_frame_free_list; p;) { Frame *cur = p; p = p->m_parent; delete cur; } }
MachineInfo() { m_cpu_num = sysconf(_SC_NPROCESSORS_CONF); m_cpu_frequencies = get_cpu_frequency_from_file("/proc/cpuinfo", m_cpu_num); if (m_cpu_frequencies) return; m_cpu_frequencies = new int64_t[m_cpu_num]; for (int i = 0; i < m_cpu_num; i++) { cpu_set_t prev_mask; GET_AFFINITY(0, sizeof(cpu_set_t), &prev_mask); BindToCPU(i); // Make sure the current process gets scheduled to the target cpu. This // might not be necessary though. usleep(0); m_cpu_frequencies[i] = get_cpu_frequency(); SET_AFFINITY(0, sizeof(cpu_set_t), &prev_mask); } }
{ \ KIND_UNBLOCK, \ index, \ { 0 }, \ { cpu0, cpu1 } \ } static const test_action test_actions[] = { RESET, UNBLOCK( 0, 0, IDLE), UNBLOCK( 1, 0, 1), UNBLOCK( 3, 0, 1), SET_PRIORITY( 1, P(2), 0, 1), SET_PRIORITY( 3, P(1), 0, 3), BLOCK( 3, 0, 1), SET_AFFINITY( 1, A(1, 1), 0, 1), SET_AFFINITY( 1, A(1, 0), 1, 0), SET_AFFINITY( 1, A(1, 1), 1, 0), SET_AFFINITY( 1, A(1, 0), 1, 0), SET_AFFINITY( 1, A(0, 1), 0, 1), BLOCK( 0, IDLE, 1), UNBLOCK( 0, 0, 1), BLOCK( 1, 0, IDLE), UNBLOCK( 1, 0, 1), RESET, /* * Show that FIFO order is honoured across all threads of the same priority. */ SET_PRIORITY( 1, P(0), IDLE, IDLE), SET_PRIORITY( 2, P(1), IDLE, IDLE), SET_PRIORITY( 3, P(1), IDLE, IDLE),
/** * Bind the current process to a specified CPU. This function is to ensure * that the OS won't schedule the process to different processors, which * would make values read by rdtsc unreliable. * * @param uint32 cpu_id, the id of the logical cpu to be bound to. * * @author cjiang */ static void BindToCPU(uint32_t cpu_id) { cpu_set_t new_mask; CPU_ZERO(&new_mask); CPU_SET(cpu_id, &new_mask); SET_AFFINITY(0, sizeof(cpu_set_t), &new_mask); }