MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / bindThreadToCpu

Function bindThreadToCpu

runtime/Perf.cc:63–69  ·  view source on GitHub ↗

* Ask the operating system to pin the current thread to a given CPU. * * \param cpu * Indicates the desired CPU and hyperthread; low order 2 bits * specify CPU, next bit specifies hyperthread. */

Source from the content-addressed store, hash-verified

61 * specify CPU, next bit specifies hyperthread.
62 */
63void bindThreadToCpu(int cpu)
64{
65 cpu_set_t set;
66 CPU_ZERO(&set);
67 CPU_SET(cpu, &set);
68 sched_setaffinity((pid_t)syscall(SYS_gettid), sizeof(set), &set);
69}
70
71/*
72 * This function just discards its argument. It's used to make it

Callers 2

readerThreadFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected