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"
8 p_online \- return or change processor operational status
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);
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.
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
31 When \fIflag\fR is \fBP_STATUS,\fR no processor status change occurs, but the
32 current processor status is returned.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
101 The \fBp_online()\fR function will fail if:
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.
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.
139 The specified processor is powered off, and the platform does not support power
140 on of individual processors.
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.
155 \fBExample 1 \fRList the legal processor numbers.
158 The following code sample will list the legal processor numbers:
163 #include <sys/unistd.h>
164 #include <sys/processor.h>
165 #include <sys/types.h>
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);
187 See \fBattributes\fR(5) for descriptions of the following attributes:
195 ATTRIBUTE TYPE ATTRIBUTE VALUE
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)