thread affinity
unknown
c_cpp
5 months ago
346 B
8
Indexable
void set_thread_affinity(int core_id) { cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(core_id, &cpuset); pthread_t current_thread = pthread_self(); int rc = pthread_setaffinity_np(current_thread, sizeof(cpu_set_t), &cpuset); if (rc != 0) { std::cerr << "Error setting thread affinity: " << rc << std::endl; } }
Editor is loading...
Leave a Comment