diff options
author | Dave Jones <davej@redhat.com> | 2008-07-02 18:10:48 -0400 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2008-07-02 18:10:48 -0400 |
commit | c719210577b577e0607a9001b2f9aa3753a12f2c (patch) | |
tree | ef5fcb6daada92acfba2d074b8116c2ca4387248 /bench | |
parent | f3a8e170cb0ce8198afff6249ff0694cbeffdb90 (diff) |
Factor out cpu binding to a common function.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/MHz.c | 10 | ||||
-rw-r--r-- | bench/benchmarks.c | 14 |
2 files changed, 2 insertions, 22 deletions
diff --git a/bench/MHz.c b/bench/MHz.c index 521ac76..2aa9ad3 100644 --- a/bench/MHz.c +++ b/bench/MHz.c @@ -9,9 +9,6 @@ #include <unistd.h> #include <stdlib.h> -#define _GNU_SOURCE -#define __USE_GNU -#include <sched.h> #include <string.h> #include <signal.h> @@ -27,7 +24,6 @@ static void sighandler(int sig __attribute__((unused))) void estimate_MHz(struct cpudata *cpu) { - cpu_set_t set; unsigned long long int cycles[2]; /* gotta be 64 bit */ unsigned int eax, ebx, ecx, edx; unsigned long r; @@ -40,11 +36,7 @@ void estimate_MHz(struct cpudata *cpu) return; } - if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) { - CPU_ZERO(&set); - CPU_SET(cpu->number, &set); - sched_setaffinity(getpid(), sizeof(set), &set); - } + bind_cpu(cpu); if (signal(SIGALRM, sighandler) == SIG_ERR) { printf("Some kind of signal failure.\n"); diff --git a/bench/benchmarks.c b/bench/benchmarks.c index b311000..7b61ec4 100644 --- a/bench/benchmarks.c +++ b/bench/benchmarks.c @@ -9,26 +9,14 @@ #include <asm/unistd.h> #endif -#define _GNU_SOURCE -#define __USE_GNU -#include <sched.h> - #include <sys/types.h> #include <unistd.h> void show_benchmarks(struct cpudata *cpu) { int tmp = 0; - cpu_set_t set; - - if (show_bench != 1) - return; - if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) { - CPU_ZERO(&set); - CPU_SET(cpu->number, &set); - sched_setaffinity(getpid(), sizeof(set), &set); - } + bind_cpu(cpu); #ifdef __linux__ TIME(asm volatile("int $0x80" :"=a" (tmp) :"0" (__NR_getppid)), "int 0x80"); |