From 659b81e3a95546165cd303f92cbb03a39adcd5e8 Mon Sep 17 00:00:00 2001 From: Stephen Roderick Date: Sun, 12 Jun 2011 12:25:52 -0400 Subject: [PATCH 2/3] gnulinux: Correct use of CPU mask. Log on failure to set affinity --- src/os/gnulinux/fosi_internal.cpp | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/os/gnulinux/fosi_internal.cpp b/src/os/gnulinux/fosi_internal.cpp index 1752021..8ce2878 100644 --- a/src/os/gnulinux/fosi_internal.cpp +++ b/src/os/gnulinux/fosi_internal.cpp @@ -123,7 +123,11 @@ namespace RTT start_routine, obj); log(Debug) <<"Created Posix thread "<< task->thread <thread != 0) { cpu_set_t cs; CPU_ZERO(&cs); - for(unsigned i = 0; i < sizeof(cpu_affinity); i++) + for(unsigned i = 0; i < 8*sizeof(cpu_affinity); i++) { if(cpu_affinity & (1 << i)) { CPU_SET(i, &cs); } } @@ -332,7 +336,7 @@ namespace RTT unsigned cpu_affinity = 0; cpu_set_t cs; pthread_getaffinity_np(task->thread, sizeof(cs), &cs); - for(unsigned i = 0; i < sizeof(cpu_affinity); i++) + for(unsigned i = 0; i < 8*sizeof(cpu_affinity); i++) { if(CPU_ISSET(i, &cs)) { cpu_affinity |= (1 << i); } } -- 1.7.4.4