4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 #include <sys/types.h>
29 #include <sys/procset.h>
30 #include <sys/processor.h>
32 #include <sys/param.h>
33 #include <sys/loadavg.h>
37 /* subcode wrappers for _pset system call */
40 pset_create(psetid_t
*npset
)
42 return (_pset(PSET_CREATE
, npset
));
46 pset_destroy(psetid_t pset
)
48 return (_pset(PSET_DESTROY
, pset
));
52 pset_assign(psetid_t pset
, processorid_t cpu
, psetid_t
*opset
)
54 return (_pset(PSET_ASSIGN
, pset
, cpu
, opset
));
58 pset_assign_forced(psetid_t pset
, processorid_t cpu
, psetid_t
*opset
)
60 return (_pset(PSET_ASSIGN_FORCED
, pset
, cpu
, opset
));
64 pset_info(psetid_t pset
, int *type
, uint_t
*numcpus
, processorid_t
*cpulist
)
66 return (_pset(PSET_INFO
, pset
, type
, numcpus
, cpulist
));
70 pset_bind(psetid_t pset
, idtype_t idtype
, id_t id
, psetid_t
*opset
)
72 return (_pset(PSET_BIND
, pset
, idtype
, id
, opset
));
76 pset_bind_lwp(psetid_t pset
, id_t id
, pid_t pid
, psetid_t
*opset
)
78 return (_pset(PSET_BIND_LWP
, pset
, id
, pid
, opset
));
82 * Get the per-processor-set load average.
85 pset_getloadavg(psetid_t pset
, double loadavg
[], int nelem
)
87 int i
, buf
[LOADAVG_NSTATS
];
89 if (nelem
> LOADAVG_NSTATS
)
90 nelem
= LOADAVG_NSTATS
;
92 if (_pset(PSET_GETLOADAVG
, pset
, buf
, nelem
) == -1)
95 for (i
= 0; i
< nelem
; i
++)
96 loadavg
[i
] = (double)buf
[i
] / FSCALE
;
102 pset_list(psetid_t
*psetlist
, uint_t
*numpsets
)
104 return (_pset(PSET_LIST
, psetlist
, numpsets
));
108 pset_setattr(psetid_t pset
, uint_t attr
)
110 return (_pset(PSET_SETATTR
, pset
, attr
));
114 pset_getattr(psetid_t pset
, uint_t
*attr
)
116 return (_pset(PSET_GETATTR
, pset
, attr
));