diff options
author | Giorgis Georgakoudis <g.georgakoudis@qub.ac.uk> | 2018-06-05 22:39:05 +0100 |
---|---|---|
committer | Giorgis Georgakoudis <g.georgakoudis@qub.ac.uk> | 2018-06-05 22:39:05 +0100 |
commit | af8c6a9cedb5e431928647526e524d890e700b8e (patch) | |
tree | a2433b18abdee2c07f87387a4e7951c55386c17d /src/thread.cpp | |
parent | e7149600fdd8d1f4fe98f95ad85dde9a806c4820 (diff) |
Fixed cpu count discovery and affinity
Diffstat (limited to 'src/thread.cpp')
-rw-r--r-- | src/thread.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/thread.cpp b/src/thread.cpp index 401b388..00195ee 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -53,17 +53,13 @@ Thread::start_routine(void* p) { // deduce the amount of CPUs int count = 0; - for (int i = 0; i < 8; i++) - { - if (CPU_ISSET(i, &cs)) - count++; - } + for (; CPU_ISSET(count, &cs); count++); // restrict to a single CPU CPU_ZERO(&cs); size_t size = CPU_ALLOC_SIZE(1); CPU_SET_S(((Thread*) p)->id % count, size, &cs); - sched_setaffinity(pthread_self(), size, &cs); + pthread_setaffinity_np(pthread_self(), size, &cs); // run ((Thread*) p)->run(); |