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

Function pinThreadToCore

runtime/Util.h:91–98  ·  view source on GitHub ↗

* This function pins the currently executing thread onto the CPU Core with * the id given in the argument. * * \param id * The id of the core to pin the caller's thread to. */

Source from the content-addressed store, hash-verified

89 * The id of the core to pin the caller's thread to.
90 */
91static FORCE_INLINE
92void pinThreadToCore(int id) {
93 cpu_set_t cpuset;
94
95 CPU_ZERO(&cpuset);
96 CPU_SET(id, &cpuset);
97 assert(sched_setaffinity(0, sizeof(cpuset), &cpuset) == 0);
98}
99
100/**
101 * Returns the cpu affinity mask of the currently executing thread. The type

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected