1 .\" $NetBSD: pset.3,v 1.9 2009/01/28 23:44:45 dyoung Exp $
3 .\" Copyright (c) 2008 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Mindaugas Rasiukevicius <rmind at NetBSD org>.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
42 .Fn pset_create "psetid_t *psid"
44 .Fn pset_assign "psetid_t psid" "cpuid_t cpuid" "psetid_t *opsid"
46 .Fn pset_bind "psetid_t psid" "idtype_t type" "id_t id" "psetid_t *opsid"
48 .Fn pset_destroy "psetid_t psid"
50 The processor sets API provides the possibility to exclusively
51 dedicate specific processors or groups of processors to processes
53 After processes or threads are bound to a group of processors by
54 the API, the group henceforth runs only those processes or threads.
55 This section describes the functions used to control processor sets.
57 .Bl -tag -width compact
58 .It Fn pset_create psid
59 Creates a processor set, and returns its ID into
61 .It Fn pset_assign psid cpu opsid
62 Assigns the processor specified by
64 to the processor set specified by
66 Stores the current processor set ID of the processor or
77 then the current processor set ID will be returned into
79 and no assignment will be performed.
85 then the processor set ID of the calling process will be used, and
93 any assignment to the processor will be cleared.
94 .It Fn pset_bind psid type id opsid
95 Dedicates the processor set specified by
97 to the target specified by
99 The current processor set ID to which the target is bound or
103 if the pointer is not
106 supports the following types of targets specified by
108 .Bl -tag -width P_PID
110 Process identified by the PID.
112 Thread of the calling process indentified by the LID.
119 then the current processor set ID to which the target is bound or
123 and no binding will be performed.
128 then the processor set ID of the calling process will be used.
134 the specified target will be unbound from the processor set.
135 .It Fn pset_destroy psid
136 Destroys the processor set specified by
138 Before destroying the processor set, all related assignments of the
139 processors will be cleared, and all bound threads will be unbound.
145 the processor set ID of the caller thread will be used.
150 function can return the current processor set ID to which the
153 However, for example, the process may have many threads, which could be
154 bound to different processor sets.
155 In such a case it is unspecified which thread will be used to return
158 There is an alternative thread affinity interface, see
160 However, processor sets and thread affinity are mutually exclusive,
161 hence mixing of these interfaces is prohibited.
163 Upon successful completion these functions return 0.
164 Otherwise, \-1 is returned and
166 is set to indicate the error.
168 An example of code fragment, which assigns the CPU whose ID is 0,
174 if (pset_create(\*[Am]psid) \*[Lt] 0)
175 err(EXIT_FAILURE, "pset_create");
177 /* Assign CPU 0 to the processor-set */
178 if (pset_assign(psid, ci, NULL) \*[Lt] 0)
179 err(EXIT_FAILURE, "pset_assign");
181 /* Bind the current process to the processor-set */
182 if (pset_bind(psid, P_PID, P_MYID, NULL) \*[Lt] 0)
183 err(EXIT_FAILURE, "pset_bind");
186 * At this point, CPU 0 runs only the current process.
190 if (pset_destroy(psid) \*[Lt] 0)
191 err(EXIT_FAILURE, "pset_destroy");
199 No memory is available for creation of the processor set, or limit
200 of the allowed count of the processor sets was reached.
202 The calling process is not the super-user.
210 Another operation is performing on the processor set.
217 The calling process is not the super-user, and
228 Another operation is performing on the processor set.
235 The calling process is not the super-user, and
240 The specified target was not found.
248 Another operation is performing on the processor set.
250 The calling process is not the super-user.
258 This API is expected to be compatible with the APIs found in Solaris and
259 HP-UX operating systems.
261 The processor sets appeared in