Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Feb 2008 11:34:09 -0500 (EST)
From:      Daniel Eischen <deischen@freebsd.org>
To:        Jeff Roberson <jroberson@chesapeake.net>
Cc:        arch@freebsd.org, Robert Watson <rwatson@freebsd.org>, David Xu <davidxu@freebsd.org>, Andrew Gallatin <gallatin@cs.duke.edu>
Subject:   Re: getaffinity/setaffinity and cpu sets.
Message-ID:  <Pine.GSO.4.64.0802211131460.12988@sea.ntplx.net>
In-Reply-To: <20080220213253.A920@desktop>
References:  <20071219211025.T899@desktop> <18311.49715.457070.397815@grasshopper.cs.duke.edu> <20080112182948.F36731@fledge.watson.org> <20080112170831.A957@desktop> <Pine.GSO.4.64.0801122240510.15683@sea.ntplx.net> <20080112194521.I957@desktop> <20080219234101.D920@desktop> <20080220101348.D44565@fledge.watson.org> <20080220005030.Y920@desktop> <20080220105333.G44565@fledge.watson.org> <47BCEFDB.5040207@freebsd.org> <20080220175532.Q920@desktop> <20080220213253.A920@desktop>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 20 Feb 2008, Jeff Roberson wrote:

> I have the following api working:
>
> /*
> * Parameters for the level argument to getaffinity.
> */
> #define CPU_LEVEL_SYS   1       /* All system cpus. */
> #define CPU_LEVEL_AVAIL 2       /* Available cpus for which. */
> #define CPU_LEVEL_WHICH 3       /* Actual mask for which. */
>
> /*
> * Parameters for the which argument to {get,set}affinity.
> */
> #define CPU_WHICH_TID   1       /* Specifies a thread id. */
> #define CPU_WHICH_PID   2       /* Specifies a process id. */
> #define CPU_WHICH_SET   3       /* Specifies a set id. */
>
>
> Along with a CPU_CLR, CPU_COPY, CPU_ISSET, CPU_SET, CPU_ZERO for manipulating 
> the sets.
>
> int getaffinity(int level, int which, int id, int cpusetsize, long *mask);
> int setaffinity(int which, int id, int cpusetsize, long *mask);
>
> The get call has a notion of 'level' which allows us to fetch different 
> masks.  The system set is all processors in the system.  The available set is 
> the set of cpus available to the tid/pid in the 'which' argument.  An 
> application would fetch the avail set and then potentially reduce it.
>
> The setaffinity call doesn't have a level because the avail/sys sets are 
> immutable.  You can only set things which can be specified by the which 
> argument.

Everything looks pretty good to me, but if you add the 'level' to
setaffinity(), you might be able to say "run on any ONE of the CPUs
in the cpuset - I don't care which one".

-- 
DE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0802211131460.12988>