MCPcopy Create free account
hub / github.com/Abc-Arbitrage/Disruptor-cpp / sched_getaffinity

Function sched_getaffinity

Disruptor/ThreadHelper_macOS.cpp:51–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 static inline int CPU_ISSET(int num, cpu_set_t *cs) { return (cs->count & (1 << num)); }
50
51 int sched_getaffinity(pid_t pid, size_t cpu_size, cpu_set_t *cpu_set)
52 {
53 (void) pid;
54 (void) cpu_size;
55
56 int32_t core_count = 0;
57 size_t len = sizeof(core_count);
58 int ret = sysctlbyname(SYSCTL_CORE_COUNT, &core_count, &len, 0, 0);
59 if (ret) {
60 return -1;
61 }
62 cpu_set->count = 0;
63 for (int i = 0; i < core_count; i++) {
64 cpu_set->count |= (1 << i);
65 }
66
67 return 0;
68 }
69
70 int pthread_setaffinity_np(pthread_t thread, size_t cpu_size,
71 cpu_set_t *cpu_set)

Callers 1

getThreadAffinityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected