From 0df168cc6ff8d5c2a9216d3bcb58149271e2c716 Mon Sep 17 00:00:00 2001 From: lye Date: Wed, 17 Apr 2013 00:17:27 -0500 Subject: [PATCH] Add FreeBSD support for setting CPU affinity. --- cpu-miner.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cpu-miner.c b/cpu-miner.c index 126ce03..bcc5644 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -64,6 +64,20 @@ static inline void affine_to_cpu(int id, int cpu) sched_setaffinity(0, sizeof(&set), &set); applog(LOG_INFO, "Binding thread %d to cpu %d", id, cpu); } +#elif defined(__FreeBSD__) /* FreeBSD specific policy and affinity management */ +#include +static inline void drop_policy(void) +{ +} + +static inline void affine_to_cpu(int id, int cpu) +{ + cpuset_t set; + CPU_ZERO(&set); + CPU_SET(cpu, &set); + cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_CPUSET, -1, sizeof(cpuset_t), &set); + applog(LOG_INFO, "Binding thread %d to cpu %d", id, cpu); +} #else static inline void drop_policy(void) {