5754 prtconf: assertion failure in libpcidb if vendor cannot be looked up
[illumos-gate.git] / usr / src / man / man2 / p_online.2
blob4506daa0818f9371c6575167941bcde6dd5e60b0
1 '\" te
2 .\" Copyright (c) 2009, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH P_ONLINE 2 "Jan 11, 2009"
7 .SH NAME
8 p_online \- return or change processor operational status
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/types.h>
13 #include <sys/processor.h>
15 \fBint\fR \fBp_online\fR(\fBprocessorid_t\fR \fIprocessorid\fR, \fBint\fR \fIflag\fR);
16 .fi
18 .SH DESCRIPTION
19 .sp
20 .LP
21 The \fBp_online()\fR function changes or returns the operational status of
22 processors. The state of the processor specified by the \fIprocessorid\fR
23 argument is changed to the state represented by the \fIflag\fR argument.
24 .sp
25 .LP
26 Legal values for \fIflag\fR are \fBP_STATUS\fR, \fBP_ONLINE\fR,
27 \fBP_OFFLINE\fR, \fBP_NOINTR\fR, \fBP_FAULTED\fR, \fBP_SPARE\fR, and
28 \fBP_FORCED\fR.
29 .sp
30 .LP
31 When \fIflag\fR is \fBP_STATUS,\fR no processor status change occurs, but the
32 current processor status is returned.
33 .sp
34 .LP
35 The \fBP_ONLINE\fR, \fBP_OFFLINE\fR, \fBP_NOINTR\fR, \fBP_FAULTED\fR, and
36 \fBP_SPARE\fR values for \fIflag\fR refer to valid processor states. The
37 \fBP_OFFLINE\fR, \fBP_SPARE\fR,  and \fBP_FAULTED\fR processor states can be
38 combined with the \fBP_FORCED\fR flag.
39 .sp
40 .LP
41 A processor in the \fBP_ONLINE\fR state is allowed to process \fBLWPs\fR
42 (lightweight processes) and perform system activities. The processor is also
43 interruptible by I/O devices attached to the system.
44 .sp
45 .LP
46 A processor in the \fBP_OFFLINE\fR state is not allowed to process \fBLWPs\fR.
47 The processor is as inactive as possible. If the hardware supports such a
48 feature, the processor is not interruptible by attached I/O devices.
49 .sp
50 .LP
51 A processor in the \fBP_NOINTR\fR state is allowed to process \fBLWPs\fR, but
52 it is not interruptible by attached I/O devices. Typically, interrupts, when
53 they occur are routed to other processors in the system. Not all systems
54 support putting a processor into the \fBP_NOINTR\fR state. It is not permitted
55 to put all the processors of a system into the \fBP_NOINTR\fR state. At least
56 one processor must always be available to service system clock interrupts.
57 .sp
58 .LP
59 A processor in the \fBP_SPARE\fR state is not allowed to process LWPs. In many
60 respects the \fBP_SPARE\fR state is similiar to the \fBP_OFFLINE\fR state, but
61 describes a processor that is available for reactivation by management tools
62 without administrator intervention.
63 .sp
64 .LP
65 A processor in the \fBP_FAULTED\fR state is not allowed to process LWPs. In
66 many respects the \fBP_FAULTED\fR state is similiar to the \fBP_OFFLINE\fR
67 state, but describes a processor that has been diagnosed as faulty. The
68 privileged caller can change the state of the processor from \fBP_FAULTED\fR to
69 any of the other states, but since the processor might generate additional
70 errors, electing to reactivate such a processor should be carefully considered.
71 .sp
72 .LP
73 Forced processor state transition can be requested if a new processor state is
74 specified with the bitwise-inclusive OR of the special \fBP_FORCED\fR flag.
75 Forcing transition of a processor to the \fBP_OFFLINE\fR, \fBP_SPARE\fR, or
76 \fBP_FAULTED\fR state revokes processor bindings for all threads that were
77 previously bound to that processor with \fBprocessor_bind\fR(2). There is no
78 guarantee that a forced processor state transition always succeeds.
79 .sp
80 .LP
81 Processor numbers are integers, greater than or equal to 0, and are defined by
82 the hardware platform.  Processor numbers are not necessarily contiguous, but
83 "not too sparse."  Processor numbers should always be printed in decimal.
84 .sp
85 .LP
86 The maximum possible \fIprocessorid\fR value can be determined by calling
87 \fBsysconf(_SC_CPUID_MAX)\fR. The list of valid processor numbers can be
88 determined by calling \fBp_online()\fR with \fIprocessorid\fR values from 0 to
89 the maximum returned by \fBsysconf(_SC_CPUID_MAX)\fR. The \fBEINVAL\fR error is
90 returned for invalid processor numbers.  See \fBEXAMPLES\fR below.
91 .SH RETURN VALUES
92 .sp
93 .LP
94 On successful completion, the value returned is the previous state of the
95 processor, \fBP_ONLINE\fR, \fBP_OFFLINE\fR, \fBP_NOINTR\fR, \fBP_FAULTED\fR,
96 \fBP_SPARE\fR, or \fBP_POWEROFF\fR. Otherwise, \fB\(mi1\fR is returned, the CPU
97 state remains unchanged, and  \fBerrno\fR is set to indicate the error.
98 .SH ERRORS
99 .sp
101 The \fBp_online()\fR function will fail if:
103 .ne 2
105 \fB\fBEBUSY\fR\fR
107 .RS 11n
108 The \fIflag\fR was \fBP_OFFLINE\fR or \fBP_SPARE\fR and the specified processor
109 is the only on-line processor, there are currently  \fBLWPs\fR bound to the
110 processor, or the processor performs some essential function that cannot be
111 performed by another processor.
113 The \fIflag\fR was \fBP_NOINTR\fR and the specified processor is the only
114 interruptible processor in the system, or it handles interrupts that cannot be
115 handled by another processor.
117 The specified processor is powered off and cannot be powered on because some
118 platform- specific resource is not available.
122 .ne 2
124 \fB\fBEINVAL\fR\fR
126 .RS 11n
127 A non-existent processor \fBID\fR was specified or  \fIflag\fR was invalid.
129 The caller is in a non-global zone, the pools facility is active, and the
130 processor is not a member of the zone's pool's processor set.
134 .ne 2
136 \fB\fBENOTSUP\fR\fR
138 .RS 11n
139 The specified processor is powered off, and the platform does not support power
140 on of individual processors.
144 .ne 2
146 \fB\fBEPERM\fR\fR
148 .RS 11n
149 The flag was not \fBP_STATUS\fR and the {\fBPRIV_SYS_RES_CONFIG\fR} privilege
150 is not asserted in the effective set of the calling process.
153 .SH EXAMPLES
155 \fBExample 1 \fRList the legal processor numbers.
158 The following code sample will list the legal processor numbers:
161 .in +2
163 #include <sys/unistd.h>
164 #include <sys/processor.h>
165 #include <sys/types.h>
166 #include <stdio.h>
167 #include <unistd.h>
168 #include <errno.h>
171 main()
173         processorid_t i, cpuid_max;
174         cpuid_max = sysconf(_SC_CPUID_MAX);
175         for (i = 0; i <= cpuid_max; i++) {
176               if (p_online(i, P_STATUS) != -1)
177                         printf("processor %d present\en", i);
178         }
179         return (0);
182 .in -2
184 .SH ATTRIBUTES
187 See \fBattributes\fR(5) for descriptions of the following attributes:
192 box;
193 c | c
194 l | l .
195 ATTRIBUTE TYPE  ATTRIBUTE VALUE
197 MT-Level        MT-Safe
200 .SH SEE ALSO
203 \fBpooladm\fR(1M), \fBpsradm\fR(1M), \fBpsrinfo\fR(1M), \fBzoneadm\fR(1M),
204 \fBprocessor_bind\fR(2), \fBprocessor_info\fR(2), \fBpset_create\fR(2),
205 \fBsysconf\fR(3C), \fBattributes\fR(5), \fBprivileges\fR(5)