Subject: Re: Syscalls to set CPU affinity
To: None <tech-kern@netbsd.org>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 09/12/2007 12:49:23
On Wed, Sep 12, 2007 at 02:13:11AM +0100, Andrew Doran wrote:
> On Mon, Sep 10, 2007 at 02:06:25AM +0300, Mindaugas R. wrote:
> > Hello,
> > 
> > I would like to discuss the API for setting and getting the affinity for
> > processes and threads, and operations with CPU sets. My suggestion would be
> > adopting the Solaris API, which looks flexible and good for compatibility:
> > 
> > int processor_bind(idtype_t idtype, id_t id, processorid_t processorid,
> >     processorid_t *obind);

http://docs.sun.com/app/docs/doc/819-2241/6n4huc7m4?l=it&a=view

> > int pset_bind(psetid_t pset, idtype_t idtype, id_t id, psetid_t *opset);
> > int pset_create(psetid_t *newpset);
> > int pset_destroy(psetid_t pset);
> > int pset_assign(psetid_t pset, processorid_t cpu, psetid_t *opset);

http://docs.sun.com/app/docs/doc/819-2241/6n4huc7m8?l=it&a=view

> > Calls of Linux API can set affinity only for processes, however I think it
> > would be reasonable to have a support for Linux affinity calls in libpthread
> > for compatibility purposes:
> > 
> > int sched_setaffinity(pid_t pid, unsigned int cpusetsize, cpu_set_t *mask);
> > int sched_getaffinity(pid_t pid, unsigned int cpusetsize, cpu_set_t *mask);

http://linux.die.net/man/2/sched_setaffinity

Andrew