Setting CPU affinity to process( Freebsd smp kernel)
julian at elischer.org
Fri Feb 23 20:34:34 UTC 2007
Kunze, Aaron wrote:
> Thanks for the info. The Linux equivalent would be sched_setaffinity
> which takes a bitmask as input, allowing the user to define which
> processors will run a particular thread. Here's a link:
>>> There's a potential for
>>> conflict between the kernel's use of pinning and binding for kernel
>>> synchronization and the user space affinity model, which will be
> Can you elaborate on this? Some of my colleagues and I are considering
> tackling this and would like to avoid such pitfalls, if possible.
>> I know Solaris has processor_bind(2) and pset_bind(2):
I prefer the linux model but it does limit you to some set number of procesors.
it looks however that the solaris interface doesn't allow 'sets' of processors but
just allows you to specify a single processor.
I would postulate the following syscall copied from Linux.
As in Linux, the 'pid_t' can specify a TID in which case
the give thread is changed
I would suggest that it would have to be a thread in the current process however.
(you don't allow threads to be manipulated from outside the process)
It's not obvious from the man page if a pid of 0 afects the current process or thread.
I read it as being process, with no way of specifying the current thread.
I would add a PID/TID of (-1) to indicate 'current (kernel) thread'.
In addition it is possible that a UTS mailbox might specify a set I guess for
kse type threads.
sched_getaffinity(pid_t pid, unsigned int cpusetsize, cpu_set_t *mask);
void CPU_CLR(int cpu, cpu_set_t *set);
int CPU_ISSET(int cpu, cpu_set_t *set);
void CPU_SET(int cpu, cpu_set_t *set);
void CPU_ZERO(cpu_set_t *set);
> freebsd-smp at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-smp-unsubscribe at freebsd.org"
More information about the freebsd-smp