1p_online(2) System Calls p_online(2)
2
3
4
6 p_online - return or change processor operational status
7
9 #include <sys/types.h>
10 #include <sys/processor.h>
11
12 int p_online(processorid_t processorid, int flag);
13
14
16 The p_online() function changes or returns the operational status of
17 processors. The state of the processor specified by the processorid
18 argument is changed to the state represented by the flag argument.
19
20
21 Legal values for flag are P_STATUS, P_ONLINE, P_OFFLINE, P_NOINTR,
22 P_FAULTED, P_SPARE, and P_FORCED.
23
24
25 When flag is P_STATUS, no processor status change occurs, but the cur‐
26 rent processor status is returned.
27
28
29 The P_ONLINE, P_OFFLINE, P_NOINTR, P_FAULTED, and P_SPARE values for
30 flag refer to valid processor states. The P_OFFLINE, P_SPARE, and
31 P_FAULTED processor states can be combined with the P_FORCED flag.
32
33
34 A processor in the P_ONLINE state is allowed to process LWPs (light‐
35 weight processes) and perform system activities. The processor is also
36 interruptible by I/O devices attached to the system.
37
38
39 A processor in the P_OFFLINE state is not allowed to process LWPs. The
40 processor is as inactive as possible. If the hardware supports such a
41 feature, the processor is not interruptible by attached I/O devices.
42
43
44 A processor in the P_NOINTR state is allowed to process LWPs, but it is
45 not interruptible by attached I/O devices. Typically, interrupts, when
46 they occur are routed to other processors in the system. Not all sys‐
47 tems support putting a processor into the P_NOINTR state. It is not
48 permitted to put all the processors of a system into the P_NOINTR
49 state. At least one processor must always be available to service sys‐
50 tem clock interrupts.
51
52
53 A processor in the P_SPARE state is not allowed to process LWPs. In
54 many respects the P_SPARE state is similiar to the P_OFFLINE state, but
55 describes a processor that is available for reactivation by management
56 tools without administrator intervention.
57
58
59 A processor in the P_FAULTED state is not allowed to process LWPs. In
60 many respects the P_FAULTED state is similiar to the P_OFFLINE state,
61 but describes a processor that has been diagnosed as faulty. The privi‐
62 leged caller can change the state of the processor from P_FAULTED to
63 any of the other states, but since the processor might generate addi‐
64 tional errors, electing to reactivate such a processor should be care‐
65 fully considered.
66
67
68 Forced processor state transition can be requested if a new processor
69 state is specified with the bitwise-inclusive OR of the special
70 P_FORCED flag. Forcing transition of a processor to the P_OFFLINE,
71 P_SPARE, or P_FAULTED state revokes processor bindings for all threads
72 that were previously bound to that processor with processor_bind(2).
73 There is no guarantee that a forced processor state transition always
74 succeeds.
75
76
77 Processor numbers are integers, greater than or equal to 0, and are
78 defined by the hardware platform. Processor numbers are not necessar‐
79 ily contiguous, but "not too sparse." Processor numbers should always
80 be printed in decimal.
81
82
83 The maximum possible processorid value can be determined by calling
84 sysconf(_SC_CPUID_MAX). The list of valid processor numbers can be
85 determined by calling p_online() with processorid values from 0 to the
86 maximum returned by sysconf(_SC_CPUID_MAX). The EINVAL error is
87 returned for invalid processor numbers. See EXAMPLES below.
88
90 On successful completion, the value returned is the previous state of
91 the processor, P_ONLINE, P_OFFLINE, P_NOINTR, P_FAULTED, P_SPARE, or
92 P_POWEROFF. Otherwise, −1 is returned, the CPU state remains unchanged,
93 and errno is set to indicate the error.
94
96 The p_online() function will fail if:
97
98 EBUSY The flag was P_OFFLINE or P_SPARE and the specified proces‐
99 sor is the only on-line processor, there are currently LWPs
100 bound to the processor, or the processor performs some
101 essential function that cannot be performed by another pro‐
102 cessor.
103
104 The flag was P_NOINTR and the specified processor is the
105 only interruptible processor in the system, or it handles
106 interrupts that cannot be handled by another processor.
107
108 The specified processor is powered off and cannot be powered
109 on because some platform- specific resource is not avail‐
110 able.
111
112
113 EINVAL A non-existent processor ID was specified or flag was
114 invalid.
115
116 The caller is in a non-global zone, the pools facility is
117 active, and the processor is not a member of the zone's
118 pool's processor set.
119
120
121 ENOTSUP The specified processor is powered off, and the platform
122 does not support power on of individual processors.
123
124
125 EPERM The flag was not P_STATUS and the {PRIV_SYS_RES_CONFIG}
126 privilege is not asserted in the effective set of the call‐
127 ing process.
128
129
131 Example 1 List the legal processor numbers.
132
133
134 The following code sample will list the legal processor numbers:
135
136
137 #include <sys/unistd.h>
138 #include <sys/processor.h>
139 #include <sys/types.h>
140 #include <stdio.h>
141 #include <unistd.h>
142 #include <errno.h>
143
144 int
145 main()
146 {
147 processorid_t i, cpuid_max;
148 cpuid_max = sysconf(_SC_CPUID_MAX);
149 for (i = 0; i <= cpuid_max; i++) {
150 if (p_online(i, P_STATUS) != -1)
151 printf("processor %d present\n", i);
152 }
153 return (0);
154 }
155
156
158 See attributes(5) for descriptions of the following attributes:
159
160
161
162
163 ┌─────────────────────────────┬─────────────────────────────┐
164 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
165 ├─────────────────────────────┼─────────────────────────────┤
166 │MT-Level │MT-Safe │
167 └─────────────────────────────┴─────────────────────────────┘
168
170 pooladm(1M), psradm(1M), psrinfo(1M), zoneadm(1M), processor_bind(2),
171 processor_info(2), pset_create(2), sysconf(3C), attributes(5), privi‐
172 leges(5)
173
174
175
176SunOS 5.11 11 Jan 2009 p_online(2)