Add FreeBSD support for setting CPU affinity.

This commit is contained in:
lye 2013-04-17 00:17:27 -05:00
parent d35050c05a
commit 0df168cc6f

View file

@ -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 <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
static inline void drop_policy(void)
{