]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
d9a64523 | 2 | * Copyright (c) 2000-2018 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
0a7de745 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
2d21ac55 A |
18 | * The Original Code and all software distributed under the License are |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
29 | /* | |
30 | * Copyright (c) 1982, 1986, 1993 | |
31 | * The Regents of the University of California. All rights reserved. | |
32 | * | |
33 | * Redistribution and use in source and binary forms, with or without | |
34 | * modification, are permitted provided that the following conditions | |
35 | * are met: | |
36 | * 1. Redistributions of source code must retain the above copyright | |
37 | * notice, this list of conditions and the following disclaimer. | |
38 | * 2. Redistributions in binary form must reproduce the above copyright | |
39 | * notice, this list of conditions and the following disclaimer in the | |
40 | * documentation and/or other materials provided with the distribution. | |
41 | * 3. All advertising materials mentioning features or use of this software | |
42 | * must display the following acknowledgement: | |
43 | * This product includes software developed by the University of | |
44 | * California, Berkeley and its contributors. | |
45 | * 4. Neither the name of the University nor the names of its contributors | |
46 | * may be used to endorse or promote products derived from this software | |
47 | * without specific prior written permission. | |
48 | * | |
49 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
50 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
59 | * SUCH DAMAGE. | |
60 | * | |
61 | * @(#)resource.h 8.2 (Berkeley) 1/4/94 | |
62 | */ | |
63 | ||
64 | #ifndef _SYS_RESOURCE_H_ | |
0a7de745 | 65 | #define _SYS_RESOURCE_H_ |
1c79356b | 66 | |
9bccf70c | 67 | #include <sys/appleapiopts.h> |
91447636 A |
68 | #include <sys/cdefs.h> |
69 | #include <sys/_types.h> | |
70 | ||
39236c6e A |
71 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL |
72 | #include <stdint.h> | |
73 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ | |
74 | ||
75 | #ifndef KERNEL | |
6d2010ae A |
76 | #include <Availability.h> |
77 | #endif | |
91447636 A |
78 | |
79 | /* [XSI] The timeval structure shall be defined as described in | |
80 | * <sys/time.h> | |
91447636 | 81 | */ |
39236c6e | 82 | #include <sys/_types/_timeval.h> |
b0d623f7 | 83 | #ifdef KERNEL |
39236c6e A |
84 | #include <sys/_types/_user32_timeval.h> |
85 | #include <sys/_types/_user64_timeval.h> | |
b0d623f7 | 86 | #endif |
91447636 A |
87 | |
88 | /* The id_t type shall be defined as described in <sys/types.h> */ | |
39236c6e | 89 | #include <sys/_types/_id_t.h> |
91447636 | 90 | |
9bccf70c | 91 | |
1c79356b | 92 | /* |
91447636 A |
93 | * Resource limit type (low 63 bits, excluding the sign bit) |
94 | */ | |
0a7de745 | 95 | typedef __uint64_t rlim_t; |
91447636 A |
96 | |
97 | ||
98 | /***** | |
99 | * PRIORITY | |
100 | */ | |
101 | ||
102 | /* | |
103 | * Possible values of the first parameter to getpriority()/setpriority(), | |
104 | * used to indicate the type of the second parameter. | |
105 | */ | |
0a7de745 A |
106 | #define PRIO_PROCESS 0 /* Second argument is a PID */ |
107 | #define PRIO_PGRP 1 /* Second argument is a GID */ | |
108 | #define PRIO_USER 2 /* Second argument is a UID */ | |
91447636 | 109 | |
39236c6e | 110 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL |
0a7de745 A |
111 | #define PRIO_DARWIN_THREAD 3 /* Second argument is always 0 (current thread) */ |
112 | #define PRIO_DARWIN_PROCESS 4 /* Second argument is a PID */ | |
2d21ac55 | 113 | |
fe8ab488 A |
114 | #ifdef PRIVATE |
115 | ||
0a7de745 | 116 | #define PRIO_DARWIN_GPU 5 /* Second argument is a PID */ |
fe8ab488 A |
117 | |
118 | #define PRIO_DARWIN_GPU_ALLOW 0x1 | |
119 | #define PRIO_DARWIN_GPU_DENY 0x2 | |
120 | ||
121 | #define PRIO_DARWIN_ROLE 6 /* Second argument is a PID */ | |
122 | ||
3e170ce0 | 123 | #define PRIO_DARWIN_ROLE_DEFAULT 0x0 /* Reset to default state */ |
fe8ab488 | 124 | #define PRIO_DARWIN_ROLE_UI_FOCAL 0x1 /* On screen, focal UI */ |
3e170ce0 | 125 | #define PRIO_DARWIN_ROLE_UI 0x2 /* On screen UI, focal unknown */ |
fe8ab488 | 126 | #define PRIO_DARWIN_ROLE_NON_UI 0x3 /* Off screen, non-focal UI */ |
3e170ce0 A |
127 | #define PRIO_DARWIN_ROLE_UI_NON_FOCAL 0x4 /* On screen, non-focal UI */ |
128 | #define PRIO_DARWIN_ROLE_TAL_LAUNCH 0x5 /* Throttled-launch (for OS X TAL resume) */ | |
d9a64523 | 129 | #define PRIO_DARWIN_ROLE_DARWIN_BG 0x6 /* Throttled for running in the background */ |
fe8ab488 A |
130 | |
131 | #endif /* PRIVATE */ | |
132 | ||
91447636 A |
133 | /* |
134 | * Range limitations for the value of the third parameter to setpriority(). | |
1c79356b | 135 | */ |
0a7de745 A |
136 | #define PRIO_MIN -20 |
137 | #define PRIO_MAX 20 | |
2d21ac55 | 138 | |
0a7de745 | 139 | /* |
b7266188 | 140 | * use PRIO_DARWIN_BG to set the current thread into "background" state |
2d21ac55 A |
141 | * which lowers CPU, disk IO, and networking priorites until thread terminates |
142 | * or "background" state is revoked | |
143 | */ | |
144 | #define PRIO_DARWIN_BG 0x1000 | |
145 | ||
6d2010ae A |
146 | /* |
147 | * use PRIO_DARWIN_NONUI to restrict a process's ability to make calls to | |
fe8ab488 | 148 | * the GPU. (deprecated) |
6d2010ae A |
149 | */ |
150 | #define PRIO_DARWIN_NONUI 0x1001 | |
151 | ||
0a7de745 | 152 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ |
1c79356b | 153 | |
1c79356b | 154 | |
91447636 A |
155 | |
156 | /***** | |
157 | * RESOURCE USAGE | |
1c79356b A |
158 | */ |
159 | ||
91447636 A |
160 | /* |
161 | * Possible values of the first parameter to getrusage(), used to indicate | |
162 | * the scope of the information to be returned. | |
163 | */ | |
0a7de745 A |
164 | #define RUSAGE_SELF 0 /* Current process information */ |
165 | #define RUSAGE_CHILDREN -1 /* Current process' children */ | |
1c79356b | 166 | |
91447636 A |
167 | /* |
168 | * A structure representing an accounting of resource utilization. The | |
169 | * address of an instance of this structure is the second parameter to | |
170 | * getrusage(). | |
171 | * | |
172 | * Note: All values other than ru_utime and ru_stime are implementaiton | |
173 | * defined and subject to change in a future release. Their use | |
174 | * is discouraged for standards compliant programs. | |
175 | */ | |
0a7de745 A |
176 | struct rusage { |
177 | struct timeval ru_utime; /* user time used (PL) */ | |
178 | struct timeval ru_stime; /* system time used (PL) */ | |
39236c6e | 179 | #if __DARWIN_C_LEVEL < __DARWIN_C_FULL |
0a7de745 | 180 | long ru_opaque[14]; /* implementation defined */ |
39236c6e | 181 | #else |
91447636 A |
182 | /* |
183 | * Informational aliases for source compatibility with programs | |
184 | * that need more information than that provided by standards, | |
185 | * and which do not mind being OS-dependent. | |
186 | */ | |
0a7de745 A |
187 | long ru_maxrss; /* max resident set size (PL) */ |
188 | #define ru_first ru_ixrss /* internal: ruadd() range start */ | |
189 | long ru_ixrss; /* integral shared memory size (NU) */ | |
190 | long ru_idrss; /* integral unshared data (NU) */ | |
191 | long ru_isrss; /* integral unshared stack (NU) */ | |
192 | long ru_minflt; /* page reclaims (NU) */ | |
193 | long ru_majflt; /* page faults (NU) */ | |
194 | long ru_nswap; /* swaps (NU) */ | |
195 | long ru_inblock; /* block input operations (atomic) */ | |
196 | long ru_oublock; /* block output operations (atomic) */ | |
197 | long ru_msgsnd; /* messages sent (atomic) */ | |
198 | long ru_msgrcv; /* messages received (atomic) */ | |
199 | long ru_nsignals; /* signals received (atomic) */ | |
200 | long ru_nvcsw; /* voluntary context switches (atomic) */ | |
201 | long ru_nivcsw; /* involuntary " */ | |
202 | #define ru_last ru_nivcsw /* internal: ruadd() range end */ | |
203 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ | |
39236c6e A |
204 | }; |
205 | ||
206 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL | |
207 | /* | |
208 | * Flavors for proc_pid_rusage(). | |
209 | */ | |
0a7de745 A |
210 | #define RUSAGE_INFO_V0 0 |
211 | #define RUSAGE_INFO_V1 1 | |
212 | #define RUSAGE_INFO_V2 2 | |
213 | #define RUSAGE_INFO_V3 3 | |
214 | #define RUSAGE_INFO_V4 4 | |
f427ee49 A |
215 | #define RUSAGE_INFO_V5 5 |
216 | #define RUSAGE_INFO_CURRENT RUSAGE_INFO_V5 | |
217 | ||
218 | /* | |
219 | * Flags for RUSAGE_INFO_V5 | |
220 | */ | |
221 | #define RU_PROC_RUNS_RESLIDE 0x00000001 /* proc has reslid shared cache */ | |
39236c6e A |
222 | |
223 | typedef void *rusage_info_t; | |
224 | ||
225 | struct rusage_info_v0 { | |
226 | uint8_t ri_uuid[16]; | |
227 | uint64_t ri_user_time; | |
228 | uint64_t ri_system_time; | |
229 | uint64_t ri_pkg_idle_wkups; | |
230 | uint64_t ri_interrupt_wkups; | |
231 | uint64_t ri_pageins; | |
232 | uint64_t ri_wired_size; | |
5ba3f43e | 233 | uint64_t ri_resident_size; |
39236c6e A |
234 | uint64_t ri_phys_footprint; |
235 | uint64_t ri_proc_start_abstime; | |
236 | uint64_t ri_proc_exit_abstime; | |
91447636 A |
237 | }; |
238 | ||
39236c6e A |
239 | struct rusage_info_v1 { |
240 | uint8_t ri_uuid[16]; | |
241 | uint64_t ri_user_time; | |
242 | uint64_t ri_system_time; | |
243 | uint64_t ri_pkg_idle_wkups; | |
244 | uint64_t ri_interrupt_wkups; | |
245 | uint64_t ri_pageins; | |
246 | uint64_t ri_wired_size; | |
5ba3f43e | 247 | uint64_t ri_resident_size; |
39236c6e A |
248 | uint64_t ri_phys_footprint; |
249 | uint64_t ri_proc_start_abstime; | |
250 | uint64_t ri_proc_exit_abstime; | |
251 | uint64_t ri_child_user_time; | |
252 | uint64_t ri_child_system_time; | |
253 | uint64_t ri_child_pkg_idle_wkups; | |
254 | uint64_t ri_child_interrupt_wkups; | |
255 | uint64_t ri_child_pageins; | |
256 | uint64_t ri_child_elapsed_abstime; | |
257 | }; | |
258 | ||
259 | struct rusage_info_v2 { | |
260 | uint8_t ri_uuid[16]; | |
261 | uint64_t ri_user_time; | |
262 | uint64_t ri_system_time; | |
263 | uint64_t ri_pkg_idle_wkups; | |
264 | uint64_t ri_interrupt_wkups; | |
265 | uint64_t ri_pageins; | |
266 | uint64_t ri_wired_size; | |
5ba3f43e | 267 | uint64_t ri_resident_size; |
39236c6e A |
268 | uint64_t ri_phys_footprint; |
269 | uint64_t ri_proc_start_abstime; | |
270 | uint64_t ri_proc_exit_abstime; | |
271 | uint64_t ri_child_user_time; | |
272 | uint64_t ri_child_system_time; | |
273 | uint64_t ri_child_pkg_idle_wkups; | |
274 | uint64_t ri_child_interrupt_wkups; | |
275 | uint64_t ri_child_pageins; | |
276 | uint64_t ri_child_elapsed_abstime; | |
277 | uint64_t ri_diskio_bytesread; | |
278 | uint64_t ri_diskio_byteswritten; | |
279 | }; | |
280 | ||
fe8ab488 A |
281 | struct rusage_info_v3 { |
282 | uint8_t ri_uuid[16]; | |
283 | uint64_t ri_user_time; | |
284 | uint64_t ri_system_time; | |
285 | uint64_t ri_pkg_idle_wkups; | |
286 | uint64_t ri_interrupt_wkups; | |
287 | uint64_t ri_pageins; | |
288 | uint64_t ri_wired_size; | |
5ba3f43e | 289 | uint64_t ri_resident_size; |
fe8ab488 A |
290 | uint64_t ri_phys_footprint; |
291 | uint64_t ri_proc_start_abstime; | |
292 | uint64_t ri_proc_exit_abstime; | |
293 | uint64_t ri_child_user_time; | |
294 | uint64_t ri_child_system_time; | |
295 | uint64_t ri_child_pkg_idle_wkups; | |
296 | uint64_t ri_child_interrupt_wkups; | |
297 | uint64_t ri_child_pageins; | |
298 | uint64_t ri_child_elapsed_abstime; | |
299 | uint64_t ri_diskio_bytesread; | |
300 | uint64_t ri_diskio_byteswritten; | |
301 | uint64_t ri_cpu_time_qos_default; | |
302 | uint64_t ri_cpu_time_qos_maintenance; | |
303 | uint64_t ri_cpu_time_qos_background; | |
304 | uint64_t ri_cpu_time_qos_utility; | |
305 | uint64_t ri_cpu_time_qos_legacy; | |
306 | uint64_t ri_cpu_time_qos_user_initiated; | |
307 | uint64_t ri_cpu_time_qos_user_interactive; | |
308 | uint64_t ri_billed_system_time; | |
309 | uint64_t ri_serviced_system_time; | |
310 | }; | |
311 | ||
5ba3f43e A |
312 | struct rusage_info_v4 { |
313 | uint8_t ri_uuid[16]; | |
314 | uint64_t ri_user_time; | |
315 | uint64_t ri_system_time; | |
316 | uint64_t ri_pkg_idle_wkups; | |
317 | uint64_t ri_interrupt_wkups; | |
318 | uint64_t ri_pageins; | |
319 | uint64_t ri_wired_size; | |
320 | uint64_t ri_resident_size; | |
321 | uint64_t ri_phys_footprint; | |
322 | uint64_t ri_proc_start_abstime; | |
323 | uint64_t ri_proc_exit_abstime; | |
324 | uint64_t ri_child_user_time; | |
325 | uint64_t ri_child_system_time; | |
326 | uint64_t ri_child_pkg_idle_wkups; | |
327 | uint64_t ri_child_interrupt_wkups; | |
328 | uint64_t ri_child_pageins; | |
329 | uint64_t ri_child_elapsed_abstime; | |
330 | uint64_t ri_diskio_bytesread; | |
331 | uint64_t ri_diskio_byteswritten; | |
332 | uint64_t ri_cpu_time_qos_default; | |
333 | uint64_t ri_cpu_time_qos_maintenance; | |
334 | uint64_t ri_cpu_time_qos_background; | |
335 | uint64_t ri_cpu_time_qos_utility; | |
336 | uint64_t ri_cpu_time_qos_legacy; | |
337 | uint64_t ri_cpu_time_qos_user_initiated; | |
338 | uint64_t ri_cpu_time_qos_user_interactive; | |
339 | uint64_t ri_billed_system_time; | |
340 | uint64_t ri_serviced_system_time; | |
341 | uint64_t ri_logical_writes; | |
342 | uint64_t ri_lifetime_max_phys_footprint; | |
343 | uint64_t ri_instructions; | |
344 | uint64_t ri_cycles; | |
345 | uint64_t ri_billed_energy; | |
346 | uint64_t ri_serviced_energy; | |
0a7de745 | 347 | uint64_t ri_interval_max_phys_footprint; |
cb323159 | 348 | uint64_t ri_runnable_time; |
5ba3f43e A |
349 | }; |
350 | ||
f427ee49 A |
351 | struct rusage_info_v5 { |
352 | uint8_t ri_uuid[16]; | |
353 | uint64_t ri_user_time; | |
354 | uint64_t ri_system_time; | |
355 | uint64_t ri_pkg_idle_wkups; | |
356 | uint64_t ri_interrupt_wkups; | |
357 | uint64_t ri_pageins; | |
358 | uint64_t ri_wired_size; | |
359 | uint64_t ri_resident_size; | |
360 | uint64_t ri_phys_footprint; | |
361 | uint64_t ri_proc_start_abstime; | |
362 | uint64_t ri_proc_exit_abstime; | |
363 | uint64_t ri_child_user_time; | |
364 | uint64_t ri_child_system_time; | |
365 | uint64_t ri_child_pkg_idle_wkups; | |
366 | uint64_t ri_child_interrupt_wkups; | |
367 | uint64_t ri_child_pageins; | |
368 | uint64_t ri_child_elapsed_abstime; | |
369 | uint64_t ri_diskio_bytesread; | |
370 | uint64_t ri_diskio_byteswritten; | |
371 | uint64_t ri_cpu_time_qos_default; | |
372 | uint64_t ri_cpu_time_qos_maintenance; | |
373 | uint64_t ri_cpu_time_qos_background; | |
374 | uint64_t ri_cpu_time_qos_utility; | |
375 | uint64_t ri_cpu_time_qos_legacy; | |
376 | uint64_t ri_cpu_time_qos_user_initiated; | |
377 | uint64_t ri_cpu_time_qos_user_interactive; | |
378 | uint64_t ri_billed_system_time; | |
379 | uint64_t ri_serviced_system_time; | |
380 | uint64_t ri_logical_writes; | |
381 | uint64_t ri_lifetime_max_phys_footprint; | |
382 | uint64_t ri_instructions; | |
383 | uint64_t ri_cycles; | |
384 | uint64_t ri_billed_energy; | |
385 | uint64_t ri_serviced_energy; | |
386 | uint64_t ri_interval_max_phys_footprint; | |
387 | uint64_t ri_runnable_time; | |
388 | uint64_t ri_flags; | |
389 | }; | |
390 | ||
391 | typedef struct rusage_info_v5 rusage_info_current; | |
fe8ab488 | 392 | |
39236c6e | 393 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ |
91447636 | 394 | |
91447636 | 395 | #ifdef KERNEL |
91447636 | 396 | |
39236c6e | 397 | struct rusage_superset { |
0a7de745 A |
398 | struct rusage ru; |
399 | rusage_info_current ri; | |
39236c6e A |
400 | }; |
401 | ||
402 | struct rusage_info_child { | |
403 | uint64_t ri_child_user_time; | |
404 | uint64_t ri_child_system_time; | |
405 | uint64_t ri_child_pkg_idle_wkups; | |
406 | uint64_t ri_child_interrupt_wkups; | |
407 | uint64_t ri_child_pageins; | |
408 | uint64_t ri_child_elapsed_abstime; | |
409 | }; | |
410 | ||
0a7de745 A |
411 | struct user64_rusage { |
412 | struct user64_timeval ru_utime; /* user time used */ | |
413 | struct user64_timeval ru_stime; /* system time used */ | |
414 | user64_long_t ru_maxrss; /* max resident set size */ | |
415 | user64_long_t ru_ixrss; /* integral shared memory size */ | |
416 | user64_long_t ru_idrss; /* integral unshared data " */ | |
417 | user64_long_t ru_isrss; /* integral unshared stack " */ | |
418 | user64_long_t ru_minflt; /* page reclaims */ | |
419 | user64_long_t ru_majflt; /* page faults */ | |
420 | user64_long_t ru_nswap; /* swaps */ | |
421 | user64_long_t ru_inblock; /* block input operations */ | |
422 | user64_long_t ru_oublock; /* block output operations */ | |
423 | user64_long_t ru_msgsnd; /* messages sent */ | |
424 | user64_long_t ru_msgrcv; /* messages received */ | |
425 | user64_long_t ru_nsignals; /* signals received */ | |
426 | user64_long_t ru_nvcsw; /* voluntary context switches */ | |
427 | user64_long_t ru_nivcsw; /* involuntary " */ | |
b0d623f7 | 428 | }; |
91447636 | 429 | |
0a7de745 A |
430 | struct user32_rusage { |
431 | struct user32_timeval ru_utime; /* user time used */ | |
432 | struct user32_timeval ru_stime; /* system time used */ | |
433 | user32_long_t ru_maxrss; /* max resident set size */ | |
434 | user32_long_t ru_ixrss; /* integral shared memory size */ | |
435 | user32_long_t ru_idrss; /* integral unshared data " */ | |
436 | user32_long_t ru_isrss; /* integral unshared stack " */ | |
437 | user32_long_t ru_minflt; /* page reclaims */ | |
438 | user32_long_t ru_majflt; /* page faults */ | |
439 | user32_long_t ru_nswap; /* swaps */ | |
440 | user32_long_t ru_inblock; /* block input operations */ | |
441 | user32_long_t ru_oublock; /* block output operations */ | |
442 | user32_long_t ru_msgsnd; /* messages sent */ | |
443 | user32_long_t ru_msgrcv; /* messages received */ | |
444 | user32_long_t ru_nsignals; /* signals received */ | |
445 | user32_long_t ru_nvcsw; /* voluntary context switches */ | |
446 | user32_long_t ru_nivcsw; /* involuntary " */ | |
1c79356b A |
447 | }; |
448 | ||
b0d623f7 | 449 | #endif /* KERNEL */ |
91447636 A |
450 | |
451 | ||
452 | /***** | |
453 | * RESOURCE LIMITS | |
454 | */ | |
455 | ||
1c79356b | 456 | /* |
91447636 A |
457 | * Symbolic constants for resource limits; since all limits are representable |
458 | * as a type rlim_t, we are permitted to define RLIM_SAVED_* in terms of | |
459 | * RLIM_INFINITY. | |
1c79356b | 460 | */ |
0a7de745 A |
461 | #define RLIM_INFINITY (((__uint64_t)1 << 63) - 1) /* no limit */ |
462 | #define RLIM_SAVED_MAX RLIM_INFINITY /* Unrepresentable hard limit */ | |
463 | #define RLIM_SAVED_CUR RLIM_INFINITY /* Unrepresentable soft limit */ | |
91447636 A |
464 | |
465 | /* | |
466 | * Possible values of the first parameter to getrlimit()/setrlimit(), to | |
467 | * indicate for which resource the operation is being performed. | |
468 | */ | |
0a7de745 A |
469 | #define RLIMIT_CPU 0 /* cpu time per process */ |
470 | #define RLIMIT_FSIZE 1 /* file size */ | |
471 | #define RLIMIT_DATA 2 /* data segment size */ | |
472 | #define RLIMIT_STACK 3 /* stack size */ | |
473 | #define RLIMIT_CORE 4 /* core file size */ | |
474 | #define RLIMIT_AS 5 /* address space (resident set size) */ | |
39236c6e | 475 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL |
0a7de745 A |
476 | #define RLIMIT_RSS RLIMIT_AS /* source compatibility alias */ |
477 | #define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ | |
478 | #define RLIMIT_NPROC 7 /* number of processes */ | |
479 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ | |
480 | #define RLIMIT_NOFILE 8 /* number of open files */ | |
39236c6e | 481 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL |
0a7de745 A |
482 | #define RLIM_NLIMITS 9 /* total number of resource limits */ |
483 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ | |
484 | #define _RLIMIT_POSIX_FLAG 0x1000 /* Set bit for strict POSIX */ | |
1c79356b | 485 | |
91447636 A |
486 | /* |
487 | * A structure representing a resource limit. The address of an instance | |
488 | * of this structure is the second parameter to getrlimit()/setrlimit(). | |
489 | */ | |
1c79356b | 490 | struct rlimit { |
0a7de745 A |
491 | rlim_t rlim_cur; /* current (soft) limit */ |
492 | rlim_t rlim_max; /* maximum value for rlim_cur */ | |
1c79356b A |
493 | }; |
494 | ||
39236c6e A |
495 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL |
496 | /* | |
497 | * proc_rlimit_control() | |
498 | * | |
499 | * Resource limit flavors | |
500 | */ | |
0a7de745 A |
501 | #define RLIMIT_WAKEUPS_MONITOR 0x1 /* Configure the wakeups monitor. */ |
502 | #define RLIMIT_CPU_USAGE_MONITOR 0x2 /* Configure the CPU usage monitor. */ | |
503 | #define RLIMIT_THREAD_CPULIMITS 0x3 /* Configure a blocking, per-thread, CPU limits. */ | |
504 | #define RLIMIT_FOOTPRINT_INTERVAL 0x4 /* Configure memory footprint interval tracking */ | |
39236c6e A |
505 | |
506 | /* | |
507 | * Flags for wakeups monitor control. | |
508 | */ | |
0a7de745 A |
509 | #define WAKEMON_ENABLE 0x01 |
510 | #define WAKEMON_DISABLE 0x02 | |
511 | #define WAKEMON_GET_PARAMS 0x04 | |
512 | #define WAKEMON_SET_DEFAULTS 0x08 | |
513 | #define WAKEMON_MAKE_FATAL 0x10 /* Configure the task so that violations are fatal. */ | |
d9a64523 | 514 | |
39236c6e A |
515 | /* |
516 | * Flags for CPU usage monitor control. | |
517 | */ | |
0a7de745 | 518 | #define CPUMON_MAKE_FATAL 0x1000 |
39236c6e | 519 | |
d9a64523 A |
520 | /* |
521 | * Flags for memory footprint interval tracking. | |
522 | */ | |
0a7de745 | 523 | #define FOOTPRINT_INTERVAL_RESET 0x1 /* Reset the footprint interval counter to zero */ |
d9a64523 | 524 | |
39236c6e A |
525 | struct proc_rlimit_control_wakeupmon { |
526 | uint32_t wm_flags; | |
527 | int32_t wm_rate; | |
528 | }; | |
529 | ||
39037602 | 530 | #if PRIVATE |
0a7de745 | 531 | /* |
39037602 A |
532 | * Flags for I/O monitor control. |
533 | */ | |
0a7de745 A |
534 | #define IOMON_ENABLE 0x01 |
535 | #define IOMON_DISABLE 0x02 | |
39037602 A |
536 | |
537 | #endif /* PRIVATE */ | |
538 | ||
539 | ||
2d21ac55 | 540 | /* I/O type */ |
0a7de745 | 541 | #define IOPOL_TYPE_DISK 0 |
39236c6e A |
542 | #if PRIVATE |
543 | #define IOPOL_TYPE_VFS_HFS_CASE_SENSITIVITY 1 | |
544 | #endif | |
d9a64523 | 545 | #define IOPOL_TYPE_VFS_ATIME_UPDATES 2 |
cb323159 A |
546 | #define IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES 3 |
547 | #define IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME 4 | |
f427ee49 A |
548 | #define IOPOL_TYPE_VFS_TRIGGER_RESOLVE 5 |
549 | #define IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION 6 | |
c3c9b80d A |
550 | #define IOPOL_TYPE_VFS_IGNORE_PERMISSIONS 7 |
551 | #define IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE 8 | |
2d21ac55 A |
552 | |
553 | /* scope */ | |
554 | #define IOPOL_SCOPE_PROCESS 0 | |
555 | #define IOPOL_SCOPE_THREAD 1 | |
39236c6e | 556 | #define IOPOL_SCOPE_DARWIN_BG 2 |
2d21ac55 A |
557 | |
558 | /* I/O Priority */ | |
0a7de745 A |
559 | #define IOPOL_DEFAULT 0 |
560 | #define IOPOL_IMPORTANT 1 | |
561 | #define IOPOL_PASSIVE 2 | |
562 | #define IOPOL_THROTTLE 3 | |
563 | #define IOPOL_UTILITY 4 | |
564 | #define IOPOL_STANDARD 5 | |
39236c6e A |
565 | |
566 | /* compatibility with older names */ | |
567 | #define IOPOL_APPLICATION IOPOL_STANDARD | |
568 | #define IOPOL_NORMAL IOPOL_IMPORTANT | |
569 | ||
570 | #if PRIVATE | |
0a7de745 A |
571 | #define IOPOL_VFS_HFS_CASE_SENSITIVITY_DEFAULT 0 |
572 | #define IOPOL_VFS_HFS_CASE_SENSITIVITY_FORCE_CASE_SENSITIVE 1 | |
39236c6e | 573 | #endif |
2d21ac55 | 574 | |
0a7de745 A |
575 | #define IOPOL_ATIME_UPDATES_DEFAULT 0 |
576 | #define IOPOL_ATIME_UPDATES_OFF 1 | |
d9a64523 | 577 | |
cb323159 A |
578 | #define IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT 0 |
579 | #define IOPOL_MATERIALIZE_DATALESS_FILES_OFF 1 | |
580 | #define IOPOL_MATERIALIZE_DATALESS_FILES_ON 2 | |
581 | ||
582 | #define IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT 0 | |
583 | #define IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME 1 | |
584 | ||
f427ee49 A |
585 | #define IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT 0 |
586 | #define IOPOL_VFS_TRIGGER_RESOLVE_OFF 1 | |
587 | ||
588 | #define IOPOL_VFS_CONTENT_PROTECTION_DEFAULT 0 | |
589 | #define IOPOL_VFS_CONTENT_PROTECTION_IGNORE 1 | |
590 | ||
c3c9b80d A |
591 | #define IOPOL_VFS_IGNORE_PERMISSIONS_OFF 0 |
592 | #define IOPOL_VFS_IGNORE_PERMISSIONS_ON 1 | |
593 | ||
594 | #define IOPOL_VFS_SKIP_MTIME_UPDATE_OFF 0 | |
595 | #define IOPOL_VFS_SKIP_MTIME_UPDATE_ON 1 | |
596 | ||
2d21ac55 A |
597 | #ifdef PRIVATE |
598 | /* | |
39236c6e A |
599 | * Structures for use in communicating via iopolicysys() between Libc and the |
600 | * kernel. Not to be used by user programs directly. | |
2d21ac55 A |
601 | */ |
602 | ||
603 | /* | |
604 | * the command to iopolicysys() | |
605 | */ | |
0a7de745 A |
606 | #define IOPOL_CMD_GET 0x00000001 /* Get I/O policy */ |
607 | #define IOPOL_CMD_SET 0x00000002 /* Set I/O policy */ | |
2d21ac55 A |
608 | |
609 | /* | |
610 | * Second parameter to iopolicysys() | |
611 | */ | |
612 | struct _iopol_param_t { | |
0a7de745 | 613 | int iop_scope; /* current process or a thread */ |
2d21ac55 A |
614 | int iop_iotype; |
615 | int iop_policy; | |
616 | }; | |
617 | ||
0a7de745 | 618 | #endif /* PRIVATE */ |
39236c6e | 619 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ |
1c79356b | 620 | |
91447636 | 621 | #ifndef KERNEL |
1c79356b A |
622 | |
623 | __BEGIN_DECLS | |
0a7de745 | 624 | int getpriority(int, id_t); |
39236c6e | 625 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL |
0a7de745 | 626 | int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); |
39236c6e | 627 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ |
0a7de745 A |
628 | int getrlimit(int, struct rlimit *) __DARWIN_ALIAS(getrlimit); |
629 | int getrusage(int, struct rusage *); | |
630 | int setpriority(int, id_t, int); | |
39236c6e | 631 | #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL |
0a7de745 | 632 | int setiopolicy_np(int, int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); |
39236c6e | 633 | #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ |
0a7de745 | 634 | int setrlimit(int, const struct rlimit *) __DARWIN_ALIAS(setrlimit); |
1c79356b A |
635 | __END_DECLS |
636 | ||
0a7de745 A |
637 | #endif /* !KERNEL */ |
638 | #endif /* !_SYS_RESOURCE_H_ */ |