From af8c6a9cedb5e431928647526e524d890e700b8e Mon Sep 17 00:00:00 2001 From: Giorgis Georgakoudis Date: Tue, 5 Jun 2018 22:39:05 +0100 Subject: Fixed cpu count discovery and affinity --- src/thread.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') 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(); -- cgit v1.2.3