1 /* 2 * Copyright (c) 2000-2018 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 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. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 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 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 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. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 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_ 65 #define _SYS_RESOURCE_H_ 66 67 #include <sys/appleapiopts.h> 68 #include <sys/cdefs.h> 69 #include <sys/_types.h> 70 71 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 72 #include <stdint.h> 73 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 74 75 #ifndef KERNEL 76 #include <Availability.h> 77 #endif 78 79 /* [XSI] The timeval structure shall be defined as described in 80 * <sys/time.h> 81 */ 82 #include <sys/_types/_timeval.h> 83 #ifdef KERNEL 84 #include <sys/_types/_user32_timeval.h> 85 #include <sys/_types/_user64_timeval.h> 86 #endif 87 88 /* The id_t type shall be defined as described in <sys/types.h> */ 89 #include <sys/_types/_id_t.h> 90 91 92 /* 93 * Resource limit type (low 63 bits, excluding the sign bit) 94 */ 95 typedef __uint64_t rlim_t; 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 */ 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 */ 109 110 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 111 #define PRIO_DARWIN_THREAD 3 /* Second argument is always 0 (current thread) */ 112 #define PRIO_DARWIN_PROCESS 4 /* Second argument is a PID */ 113 /* Additional private parameters to getpriority()/setpriority() are in resource_private.h */ 114 115 /* 116 * Range limitations for the value of the third parameter to setpriority(). 117 */ 118 #define PRIO_MIN -20 119 #define PRIO_MAX 20 120 121 /* 122 * use PRIO_DARWIN_BG to set the current thread into "background" state 123 * which lowers CPU, disk IO, and networking priorites until thread terminates 124 * or "background" state is revoked 125 */ 126 #define PRIO_DARWIN_BG 0x1000 127 128 /* 129 * use PRIO_DARWIN_NONUI to restrict a process's ability to make calls to 130 * the GPU. (deprecated) 131 */ 132 #define PRIO_DARWIN_NONUI 0x1001 133 134 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 135 136 137 138 /***** 139 * RESOURCE USAGE 140 */ 141 142 /* 143 * Possible values of the first parameter to getrusage(), used to indicate 144 * the scope of the information to be returned. 145 */ 146 #define RUSAGE_SELF 0 /* Current process information */ 147 #define RUSAGE_CHILDREN -1 /* Current process' children */ 148 149 /* 150 * A structure representing an accounting of resource utilization. The 151 * address of an instance of this structure is the second parameter to 152 * getrusage(). 153 * 154 * Note: All values other than ru_utime and ru_stime are implementaiton 155 * defined and subject to change in a future release. Their use 156 * is discouraged for standards compliant programs. 157 */ 158 struct rusage { 159 struct timeval ru_utime; /* user time used (PL) */ 160 struct timeval ru_stime; /* system time used (PL) */ 161 #if __DARWIN_C_LEVEL < __DARWIN_C_FULL 162 long ru_opaque[14]; /* implementation defined */ 163 #else 164 /* 165 * Informational aliases for source compatibility with programs 166 * that need more information than that provided by standards, 167 * and which do not mind being OS-dependent. 168 */ 169 long ru_maxrss; /* max resident set size (PL) */ 170 #define ru_first ru_ixrss /* internal: ruadd() range start */ 171 long ru_ixrss; /* integral shared memory size (NU) */ 172 long ru_idrss; /* integral unshared data (NU) */ 173 long ru_isrss; /* integral unshared stack (NU) */ 174 long ru_minflt; /* page reclaims (NU) */ 175 long ru_majflt; /* page faults (NU) */ 176 long ru_nswap; /* swaps (NU) */ 177 long ru_inblock; /* block input operations (atomic) */ 178 long ru_oublock; /* block output operations (atomic) */ 179 long ru_msgsnd; /* messages sent (atomic) */ 180 long ru_msgrcv; /* messages received (atomic) */ 181 long ru_nsignals; /* signals received (atomic) */ 182 long ru_nvcsw; /* voluntary context switches (atomic) */ 183 long ru_nivcsw; /* involuntary " */ 184 #define ru_last ru_nivcsw /* internal: ruadd() range end */ 185 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 186 }; 187 188 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 189 /* 190 * Flavors for proc_pid_rusage(). 191 */ 192 #define RUSAGE_INFO_V0 0 193 #define RUSAGE_INFO_V1 1 194 #define RUSAGE_INFO_V2 2 195 #define RUSAGE_INFO_V3 3 196 #define RUSAGE_INFO_V4 4 197 #define RUSAGE_INFO_V5 5 198 #define RUSAGE_INFO_V6 6 199 #define RUSAGE_INFO_CURRENT RUSAGE_INFO_V6 200 201 /* 202 * Flags for RUSAGE_INFO_V5 203 */ 204 #define RU_PROC_RUNS_RESLIDE 0x00000001 /* proc has reslid shared cache */ 205 206 typedef void *rusage_info_t; 207 208 struct rusage_info_v0 { 209 uint8_t ri_uuid[16]; 210 uint64_t ri_user_time; 211 uint64_t ri_system_time; 212 uint64_t ri_pkg_idle_wkups; 213 uint64_t ri_interrupt_wkups; 214 uint64_t ri_pageins; 215 uint64_t ri_wired_size; 216 uint64_t ri_resident_size; 217 uint64_t ri_phys_footprint; 218 uint64_t ri_proc_start_abstime; 219 uint64_t ri_proc_exit_abstime; 220 }; 221 222 struct rusage_info_v1 { 223 uint8_t ri_uuid[16]; 224 uint64_t ri_user_time; 225 uint64_t ri_system_time; 226 uint64_t ri_pkg_idle_wkups; 227 uint64_t ri_interrupt_wkups; 228 uint64_t ri_pageins; 229 uint64_t ri_wired_size; 230 uint64_t ri_resident_size; 231 uint64_t ri_phys_footprint; 232 uint64_t ri_proc_start_abstime; 233 uint64_t ri_proc_exit_abstime; 234 uint64_t ri_child_user_time; 235 uint64_t ri_child_system_time; 236 uint64_t ri_child_pkg_idle_wkups; 237 uint64_t ri_child_interrupt_wkups; 238 uint64_t ri_child_pageins; 239 uint64_t ri_child_elapsed_abstime; 240 }; 241 242 struct rusage_info_v2 { 243 uint8_t ri_uuid[16]; 244 uint64_t ri_user_time; 245 uint64_t ri_system_time; 246 uint64_t ri_pkg_idle_wkups; 247 uint64_t ri_interrupt_wkups; 248 uint64_t ri_pageins; 249 uint64_t ri_wired_size; 250 uint64_t ri_resident_size; 251 uint64_t ri_phys_footprint; 252 uint64_t ri_proc_start_abstime; 253 uint64_t ri_proc_exit_abstime; 254 uint64_t ri_child_user_time; 255 uint64_t ri_child_system_time; 256 uint64_t ri_child_pkg_idle_wkups; 257 uint64_t ri_child_interrupt_wkups; 258 uint64_t ri_child_pageins; 259 uint64_t ri_child_elapsed_abstime; 260 uint64_t ri_diskio_bytesread; 261 uint64_t ri_diskio_byteswritten; 262 }; 263 264 struct rusage_info_v3 { 265 uint8_t ri_uuid[16]; 266 uint64_t ri_user_time; 267 uint64_t ri_system_time; 268 uint64_t ri_pkg_idle_wkups; 269 uint64_t ri_interrupt_wkups; 270 uint64_t ri_pageins; 271 uint64_t ri_wired_size; 272 uint64_t ri_resident_size; 273 uint64_t ri_phys_footprint; 274 uint64_t ri_proc_start_abstime; 275 uint64_t ri_proc_exit_abstime; 276 uint64_t ri_child_user_time; 277 uint64_t ri_child_system_time; 278 uint64_t ri_child_pkg_idle_wkups; 279 uint64_t ri_child_interrupt_wkups; 280 uint64_t ri_child_pageins; 281 uint64_t ri_child_elapsed_abstime; 282 uint64_t ri_diskio_bytesread; 283 uint64_t ri_diskio_byteswritten; 284 uint64_t ri_cpu_time_qos_default; 285 uint64_t ri_cpu_time_qos_maintenance; 286 uint64_t ri_cpu_time_qos_background; 287 uint64_t ri_cpu_time_qos_utility; 288 uint64_t ri_cpu_time_qos_legacy; 289 uint64_t ri_cpu_time_qos_user_initiated; 290 uint64_t ri_cpu_time_qos_user_interactive; 291 uint64_t ri_billed_system_time; 292 uint64_t ri_serviced_system_time; 293 }; 294 295 struct rusage_info_v4 { 296 uint8_t ri_uuid[16]; 297 uint64_t ri_user_time; 298 uint64_t ri_system_time; 299 uint64_t ri_pkg_idle_wkups; 300 uint64_t ri_interrupt_wkups; 301 uint64_t ri_pageins; 302 uint64_t ri_wired_size; 303 uint64_t ri_resident_size; 304 uint64_t ri_phys_footprint; 305 uint64_t ri_proc_start_abstime; 306 uint64_t ri_proc_exit_abstime; 307 uint64_t ri_child_user_time; 308 uint64_t ri_child_system_time; 309 uint64_t ri_child_pkg_idle_wkups; 310 uint64_t ri_child_interrupt_wkups; 311 uint64_t ri_child_pageins; 312 uint64_t ri_child_elapsed_abstime; 313 uint64_t ri_diskio_bytesread; 314 uint64_t ri_diskio_byteswritten; 315 uint64_t ri_cpu_time_qos_default; 316 uint64_t ri_cpu_time_qos_maintenance; 317 uint64_t ri_cpu_time_qos_background; 318 uint64_t ri_cpu_time_qos_utility; 319 uint64_t ri_cpu_time_qos_legacy; 320 uint64_t ri_cpu_time_qos_user_initiated; 321 uint64_t ri_cpu_time_qos_user_interactive; 322 uint64_t ri_billed_system_time; 323 uint64_t ri_serviced_system_time; 324 uint64_t ri_logical_writes; 325 uint64_t ri_lifetime_max_phys_footprint; 326 uint64_t ri_instructions; 327 uint64_t ri_cycles; 328 uint64_t ri_billed_energy; 329 uint64_t ri_serviced_energy; 330 uint64_t ri_interval_max_phys_footprint; 331 uint64_t ri_runnable_time; 332 }; 333 334 struct rusage_info_v5 { 335 uint8_t ri_uuid[16]; 336 uint64_t ri_user_time; 337 uint64_t ri_system_time; 338 uint64_t ri_pkg_idle_wkups; 339 uint64_t ri_interrupt_wkups; 340 uint64_t ri_pageins; 341 uint64_t ri_wired_size; 342 uint64_t ri_resident_size; 343 uint64_t ri_phys_footprint; 344 uint64_t ri_proc_start_abstime; 345 uint64_t ri_proc_exit_abstime; 346 uint64_t ri_child_user_time; 347 uint64_t ri_child_system_time; 348 uint64_t ri_child_pkg_idle_wkups; 349 uint64_t ri_child_interrupt_wkups; 350 uint64_t ri_child_pageins; 351 uint64_t ri_child_elapsed_abstime; 352 uint64_t ri_diskio_bytesread; 353 uint64_t ri_diskio_byteswritten; 354 uint64_t ri_cpu_time_qos_default; 355 uint64_t ri_cpu_time_qos_maintenance; 356 uint64_t ri_cpu_time_qos_background; 357 uint64_t ri_cpu_time_qos_utility; 358 uint64_t ri_cpu_time_qos_legacy; 359 uint64_t ri_cpu_time_qos_user_initiated; 360 uint64_t ri_cpu_time_qos_user_interactive; 361 uint64_t ri_billed_system_time; 362 uint64_t ri_serviced_system_time; 363 uint64_t ri_logical_writes; 364 uint64_t ri_lifetime_max_phys_footprint; 365 uint64_t ri_instructions; 366 uint64_t ri_cycles; 367 uint64_t ri_billed_energy; 368 uint64_t ri_serviced_energy; 369 uint64_t ri_interval_max_phys_footprint; 370 uint64_t ri_runnable_time; 371 uint64_t ri_flags; 372 }; 373 374 struct rusage_info_v6 { 375 uint8_t ri_uuid[16]; 376 uint64_t ri_user_time; 377 uint64_t ri_system_time; 378 uint64_t ri_pkg_idle_wkups; 379 uint64_t ri_interrupt_wkups; 380 uint64_t ri_pageins; 381 uint64_t ri_wired_size; 382 uint64_t ri_resident_size; 383 uint64_t ri_phys_footprint; 384 uint64_t ri_proc_start_abstime; 385 uint64_t ri_proc_exit_abstime; 386 uint64_t ri_child_user_time; 387 uint64_t ri_child_system_time; 388 uint64_t ri_child_pkg_idle_wkups; 389 uint64_t ri_child_interrupt_wkups; 390 uint64_t ri_child_pageins; 391 uint64_t ri_child_elapsed_abstime; 392 uint64_t ri_diskio_bytesread; 393 uint64_t ri_diskio_byteswritten; 394 uint64_t ri_cpu_time_qos_default; 395 uint64_t ri_cpu_time_qos_maintenance; 396 uint64_t ri_cpu_time_qos_background; 397 uint64_t ri_cpu_time_qos_utility; 398 uint64_t ri_cpu_time_qos_legacy; 399 uint64_t ri_cpu_time_qos_user_initiated; 400 uint64_t ri_cpu_time_qos_user_interactive; 401 uint64_t ri_billed_system_time; 402 uint64_t ri_serviced_system_time; 403 uint64_t ri_logical_writes; 404 uint64_t ri_lifetime_max_phys_footprint; 405 uint64_t ri_instructions; 406 uint64_t ri_cycles; 407 uint64_t ri_billed_energy; 408 uint64_t ri_serviced_energy; 409 uint64_t ri_interval_max_phys_footprint; 410 uint64_t ri_runnable_time; 411 uint64_t ri_flags; 412 uint64_t ri_user_ptime; 413 uint64_t ri_system_ptime; 414 uint64_t ri_pinstructions; 415 uint64_t ri_pcycles; 416 uint64_t ri_energy_nj; 417 uint64_t ri_penergy_nj; 418 uint64_t ri_secure_time_in_system; 419 uint64_t ri_secure_ptime_in_system; 420 uint64_t ri_neural_footprint; 421 uint64_t ri_lifetime_max_neural_footprint; 422 uint64_t ri_interval_max_neural_footprint; 423 uint64_t ri_reserved[9]; 424 }; 425 426 typedef struct rusage_info_v6 rusage_info_current; 427 428 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 429 430 #ifdef KERNEL 431 432 struct rusage_superset { 433 struct rusage ru; 434 rusage_info_current ri; 435 }; 436 437 struct rusage_info_child { 438 uint64_t ri_child_user_time; 439 uint64_t ri_child_system_time; 440 uint64_t ri_child_pkg_idle_wkups; 441 uint64_t ri_child_interrupt_wkups; 442 uint64_t ri_child_pageins; 443 uint64_t ri_child_elapsed_abstime; 444 }; 445 446 struct user64_rusage { 447 struct user64_timeval ru_utime; /* user time used */ 448 struct user64_timeval ru_stime; /* system time used */ 449 user64_long_t ru_maxrss; /* max resident set size */ 450 user64_long_t ru_ixrss; /* integral shared memory size */ 451 user64_long_t ru_idrss; /* integral unshared data " */ 452 user64_long_t ru_isrss; /* integral unshared stack " */ 453 user64_long_t ru_minflt; /* page reclaims */ 454 user64_long_t ru_majflt; /* page faults */ 455 user64_long_t ru_nswap; /* swaps */ 456 user64_long_t ru_inblock; /* block input operations */ 457 user64_long_t ru_oublock; /* block output operations */ 458 user64_long_t ru_msgsnd; /* messages sent */ 459 user64_long_t ru_msgrcv; /* messages received */ 460 user64_long_t ru_nsignals; /* signals received */ 461 user64_long_t ru_nvcsw; /* voluntary context switches */ 462 user64_long_t ru_nivcsw; /* involuntary " */ 463 }; 464 465 struct user32_rusage { 466 struct user32_timeval ru_utime; /* user time used */ 467 struct user32_timeval ru_stime; /* system time used */ 468 user32_long_t ru_maxrss; /* max resident set size */ 469 user32_long_t ru_ixrss; /* integral shared memory size */ 470 user32_long_t ru_idrss; /* integral unshared data " */ 471 user32_long_t ru_isrss; /* integral unshared stack " */ 472 user32_long_t ru_minflt; /* page reclaims */ 473 user32_long_t ru_majflt; /* page faults */ 474 user32_long_t ru_nswap; /* swaps */ 475 user32_long_t ru_inblock; /* block input operations */ 476 user32_long_t ru_oublock; /* block output operations */ 477 user32_long_t ru_msgsnd; /* messages sent */ 478 user32_long_t ru_msgrcv; /* messages received */ 479 user32_long_t ru_nsignals; /* signals received */ 480 user32_long_t ru_nvcsw; /* voluntary context switches */ 481 user32_long_t ru_nivcsw; /* involuntary " */ 482 }; 483 484 #endif /* KERNEL */ 485 486 487 /***** 488 * RESOURCE LIMITS 489 */ 490 491 /* 492 * Symbolic constants for resource limits; since all limits are representable 493 * as a type rlim_t, we are permitted to define RLIM_SAVED_* in terms of 494 * RLIM_INFINITY. 495 */ 496 #define RLIM_INFINITY (((__uint64_t)1 << 63) - 1) /* no limit */ 497 #define RLIM_SAVED_MAX RLIM_INFINITY /* Unrepresentable hard limit */ 498 #define RLIM_SAVED_CUR RLIM_INFINITY /* Unrepresentable soft limit */ 499 500 /* 501 * Possible values of the first parameter to getrlimit()/setrlimit(), to 502 * indicate for which resource the operation is being performed. 503 */ 504 #define RLIMIT_CPU 0 /* cpu time per process */ 505 #define RLIMIT_FSIZE 1 /* file size */ 506 #define RLIMIT_DATA 2 /* data segment size */ 507 #define RLIMIT_STACK 3 /* stack size */ 508 #define RLIMIT_CORE 4 /* core file size */ 509 #define RLIMIT_AS 5 /* address space (resident set size) */ 510 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 511 #define RLIMIT_RSS RLIMIT_AS /* source compatibility alias */ 512 #define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ 513 #define RLIMIT_NPROC 7 /* number of processes */ 514 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 515 #define RLIMIT_NOFILE 8 /* number of open files */ 516 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 517 #define RLIM_NLIMITS 9 /* total number of resource limits */ 518 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 519 #define _RLIMIT_POSIX_FLAG 0x1000 /* Set bit for strict POSIX */ 520 521 /* 522 * A structure representing a resource limit. The address of an instance 523 * of this structure is the second parameter to getrlimit()/setrlimit(). 524 */ 525 struct rlimit { 526 rlim_t rlim_cur; /* current (soft) limit */ 527 rlim_t rlim_max; /* maximum value for rlim_cur */ 528 }; 529 530 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 531 /* 532 * proc_rlimit_control() 533 * 534 * Resource limit flavors 535 */ 536 #define RLIMIT_WAKEUPS_MONITOR 0x1 /* Configure the wakeups monitor. */ 537 #define RLIMIT_CPU_USAGE_MONITOR 0x2 /* Configure the CPU usage monitor. */ 538 #define RLIMIT_THREAD_CPULIMITS 0x3 /* Configure a blocking, per-thread, CPU limits. */ 539 #define RLIMIT_FOOTPRINT_INTERVAL 0x4 /* Configure memory footprint interval tracking */ 540 541 /* 542 * Flags for wakeups monitor control. 543 */ 544 #define WAKEMON_ENABLE 0x01 545 #define WAKEMON_DISABLE 0x02 546 #define WAKEMON_GET_PARAMS 0x04 547 #define WAKEMON_SET_DEFAULTS 0x08 548 #define WAKEMON_MAKE_FATAL 0x10 /* Configure the task so that violations are fatal. */ 549 550 /* 551 * Flags for CPU usage monitor control. 552 */ 553 #define CPUMON_MAKE_FATAL 0x1000 554 555 /* 556 * Flags for memory footprint interval tracking. 557 */ 558 #define FOOTPRINT_INTERVAL_RESET 0x1 /* Reset the footprint interval counter to zero */ 559 560 struct proc_rlimit_control_wakeupmon { 561 uint32_t wm_flags; 562 int32_t wm_rate; 563 }; 564 565 /* Additional private I/O policies are in resource_private.h */ 566 567 /* I/O type */ 568 #define IOPOL_TYPE_DISK 0 569 #define IOPOL_TYPE_VFS_ATIME_UPDATES 2 570 #define IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES 3 571 #define IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME 4 572 #define IOPOL_TYPE_VFS_TRIGGER_RESOLVE 5 573 #define IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION 6 574 #define IOPOL_TYPE_VFS_IGNORE_PERMISSIONS 7 575 #define IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE 8 576 #define IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES 9 577 #define IOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY 10 578 579 /* scope */ 580 #define IOPOL_SCOPE_PROCESS 0 581 #define IOPOL_SCOPE_THREAD 1 582 #define IOPOL_SCOPE_DARWIN_BG 2 583 584 /* I/O Priority */ 585 #define IOPOL_DEFAULT 0 586 #define IOPOL_IMPORTANT 1 587 #define IOPOL_PASSIVE 2 588 #define IOPOL_THROTTLE 3 589 #define IOPOL_UTILITY 4 590 #define IOPOL_STANDARD 5 591 592 /* compatibility with older names */ 593 #define IOPOL_APPLICATION IOPOL_STANDARD 594 #define IOPOL_NORMAL IOPOL_IMPORTANT 595 596 #define IOPOL_ATIME_UPDATES_DEFAULT 0 597 #define IOPOL_ATIME_UPDATES_OFF 1 598 599 #define IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT 0 600 #define IOPOL_MATERIALIZE_DATALESS_FILES_OFF 1 601 #define IOPOL_MATERIALIZE_DATALESS_FILES_ON 2 602 603 #define IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT 0 604 #define IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME 1 605 606 #define IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT 0 607 #define IOPOL_VFS_TRIGGER_RESOLVE_OFF 1 608 609 #define IOPOL_VFS_CONTENT_PROTECTION_DEFAULT 0 610 #define IOPOL_VFS_CONTENT_PROTECTION_IGNORE 1 611 612 #define IOPOL_VFS_IGNORE_PERMISSIONS_OFF 0 613 #define IOPOL_VFS_IGNORE_PERMISSIONS_ON 1 614 615 #define IOPOL_VFS_SKIP_MTIME_UPDATE_OFF 0 616 #define IOPOL_VFS_SKIP_MTIME_UPDATE_ON 1 617 #define IOPOL_VFS_SKIP_MTIME_UPDATE_IGNORE 2 618 619 #define IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF 0 620 #define IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON 1 621 622 #define IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT 0 623 #define IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON 1 624 625 #define IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT 0 626 #define IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON 1 627 628 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 629 630 #ifndef KERNEL 631 632 __BEGIN_DECLS 633 int getpriority(int, id_t); 634 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 635 int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); 636 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 637 int getrlimit(int, struct rlimit *) __DARWIN_ALIAS(getrlimit); 638 int getrusage(int, struct rusage *); 639 int setpriority(int, id_t, int); 640 #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL 641 int setiopolicy_np(int, int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); 642 #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ 643 int setrlimit(int, const struct rlimit *) __DARWIN_ALIAS(setrlimit); 644 __END_DECLS 645 646 #endif /* !KERNEL */ 647 648 #ifdef PRIVATE 649 #include <sys/resource_private.h> 650 #endif 651 652 #endif /* !_SYS_RESOURCE_H_ */ 653