Merge pull request #19 from lye/freebsd-cpu-pinning

Add FreeBSD support for setting CPU affinity.
This commit is contained in:
pooler 2013-05-21 13:06:54 -07:00
commit 3c4eb509a5

View file

@ -64,6 +64,20 @@ static inline void affine_to_cpu(int id, int cpu)
sched_setaffinity(0, sizeof(&set), &set); sched_setaffinity(0, sizeof(&set), &set);
applog(LOG_INFO, "Binding thread %d to cpu %d", id, cpu); applog(LOG_INFO, "Binding thread %d to cpu %d", id, cpu);
} }
#elif defined(__FreeBSD__) /* FreeBSD specific policy and affinity management */
#include <sys/cpuset.h>
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 #else
static inline void drop_policy(void) static inline void drop_policy(void)
{ {