diff --git a/src/os/win32/cpu.c b/src/os/win32/cpu.c index 89e228f9..862e5fac 100644 --- a/src/os/win32/cpu.c +++ b/src/os/win32/cpu.c @@ -241,9 +241,11 @@ unsigned int sigar_cpu_count(sigar_t *sigar) if (status == HT_ENABLED) { sigar->ht_enabled = 1; + sigar->lcpu = LogicalNum; } else { sigar->ht_enabled = 0; + sigar->lcpu = 0; } return sigar->ncpu; diff --git a/src/os/win32/sigar_os.h b/src/os/win32/sigar_os.h index 01f9e6bf..e60d1094 100644 --- a/src/os/win32/sigar_os.h +++ b/src/os/win32/sigar_os.h @@ -113,6 +113,7 @@ struct sigar_t { int ws_error; LPBYTE peb; //scratch pad for getting peb info int ht_enabled; + int lcpu; //number of logical cpus int winnt; }; diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 5c970364..707d7329 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -362,7 +362,7 @@ SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) * for each logical processor. * XXX assuming this is correct until have something to test on. */ - if (sigar->ht_enabled && ((sigar->ncpu * 2) == num)) { + if (sigar->ht_enabled && ((sigar->ncpu * sigar->lcpu) == num)) { hthread = 1; } @@ -370,7 +370,7 @@ SIGAR_DECLARE(int) sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) PERF_COUNTER_BLOCK *counter_block; sigar_cpu_t *cpu; - if (hthread && (i % 2)) { + if (hthread && (i % sigar->lcpu)) { /* merge times of logical processors */ cpu = &cpulist->data[cpulist->number-1]; }