#include <sys/resource.h>
sys/resource.h
macroPRIO_PROCESS
Possible values of the first parameter to getpriority()/setpriority(),
used to indicate the type of the second parameter.
#define PRIO_PROCESS 0
Second argument is a PID
macroPRIO_MIN
Range limitations for the value of the third parameter to setpriority().
#define PRIO_MIN -20
macroPRIO_MAX
#define PRIO_MAX 20
macroPRIO_DARWIN_BG
use PRIO_DARWIN_BG to set the current thread into "background" state
which lowers CPU, disk IO, and networking priorites until thread terminates
or "background" state is revoked
#define PRIO_DARWIN_BG 0x1000
macroPRIO_DARWIN_NONUI
use PRIO_DARWIN_NONUI to restrict a process's ability to make calls to
the GPU. (deprecated)
#define PRIO_DARWIN_NONUI 0x1001
macroRUSAGE_SELF
Possible values of the first parameter to getrusage(), used to indicate
the scope of the information to be returned.
#define RUSAGE_SELF 0
Current process information
structrusage
A structure representing an accounting of resource utilization. The
address of an instance of this structure is the second parameter to
getrusage().
Note: All values other than ru_utime and ru_stime are implementaiton
defined and subject to change in a future release. Their use
is discouraged for standards compliant programs.
| struct timeval | ru_utime | user time used (PL) |
| struct timeval | ru_stime | system time used (PL) |
| long | ru_maxrss | Informational aliases for source compatibility with programs that need more information than that provided by standards, and which do not mind being OS-dependent. max resident set size (PL) |
| long | ru_ixrss | integral shared memory size (NU) |
| long | ru_idrss | integral unshared data (NU) |
| long | ru_isrss | integral unshared stack (NU) |
| long | ru_minflt | page reclaims (NU) |
| long | ru_majflt | page faults (NU) |
| long | ru_nswap | swaps (NU) |
| long | ru_inblock | block input operations (atomic) |
| long | ru_oublock | block output operations (atomic) |
| long | ru_msgsnd | messages sent (atomic) |
| long | ru_msgrcv | messages received (atomic) |
| long | ru_nsignals | signals received (atomic) |
| long | ru_nvcsw | voluntary context switches (atomic) |
| long | ru_nivcsw | involuntary " |
macroRUSAGE_INFO_V1
#define RUSAGE_INFO_V1 1
macroRUSAGE_INFO_V2
#define RUSAGE_INFO_V2 2
macroRUSAGE_INFO_V3
#define RUSAGE_INFO_V3 3
macroRUSAGE_INFO_V4
#define RUSAGE_INFO_V4 4
macroRUSAGE_INFO_V5
#define RUSAGE_INFO_V5 5
macroRUSAGE_INFO_V6
#define RUSAGE_INFO_V6 6
macroRUSAGE_INFO_CURRENT
#define RUSAGE_INFO_CURRENT RUSAGE_INFO_V6
macroRU_PROC_RUNS_RESLIDE
Flags for RUSAGE_INFO_V5
#define RU_PROC_RUNS_RESLIDE 0x00000001
proc has reslid shared cache
typedefrusage_info_t
typedef void *rusage_info_t
structrusage_info_v0
| uint8_t[16] | ri_uuid | |
| uint64_t | ri_user_time | |
| uint64_t | ri_system_time | |
| uint64_t | ri_pkg_idle_wkups | |
| uint64_t | ri_interrupt_wkups | |
| uint64_t | ri_pageins | |
| uint64_t | ri_wired_size | |
| uint64_t | ri_resident_size | |
| uint64_t | ri_phys_footprint | |
| uint64_t | ri_proc_start_abstime | |
| uint64_t | ri_proc_exit_abstime |
structrusage_info_v1
| uint8_t[16] | ri_uuid | |
| uint64_t | ri_user_time | |
| uint64_t | ri_system_time | |
| uint64_t | ri_pkg_idle_wkups | |
| uint64_t | ri_interrupt_wkups | |
| uint64_t | ri_pageins | |
| uint64_t | ri_wired_size | |
| uint64_t | ri_resident_size | |
| uint64_t | ri_phys_footprint | |
| uint64_t | ri_proc_start_abstime | |
| uint64_t | ri_proc_exit_abstime | |
| uint64_t | ri_child_user_time | |
| uint64_t | ri_child_system_time | |
| uint64_t | ri_child_pkg_idle_wkups | |
| uint64_t | ri_child_interrupt_wkups | |
| uint64_t | ri_child_pageins | |
| uint64_t | ri_child_elapsed_abstime |
structrusage_info_v2
| uint8_t[16] | ri_uuid | |
| uint64_t | ri_user_time | |
| uint64_t | ri_system_time | |
| uint64_t | ri_pkg_idle_wkups | |
| uint64_t | ri_interrupt_wkups | |
| uint64_t | ri_pageins | |
| uint64_t | ri_wired_size | |
| uint64_t | ri_resident_size | |
| uint64_t | ri_phys_footprint | |
| uint64_t | ri_proc_start_abstime | |
| uint64_t | ri_proc_exit_abstime | |
| uint64_t | ri_child_user_time | |
| uint64_t | ri_child_system_time | |
| uint64_t | ri_child_pkg_idle_wkups | |
| uint64_t | ri_child_interrupt_wkups | |
| uint64_t | ri_child_pageins | |
| uint64_t | ri_child_elapsed_abstime | |
| uint64_t | ri_diskio_bytesread | |
| uint64_t | ri_diskio_byteswritten |
structrusage_info_v3
| uint8_t[16] | ri_uuid | |
| uint64_t | ri_user_time | |
| uint64_t | ri_system_time | |
| uint64_t | ri_pkg_idle_wkups | |
| uint64_t | ri_interrupt_wkups | |
| uint64_t | ri_pageins | |
| uint64_t | ri_wired_size | |
| uint64_t | ri_resident_size | |
| uint64_t | ri_phys_footprint | |
| uint64_t | ri_proc_start_abstime | |
| uint64_t | ri_proc_exit_abstime | |
| uint64_t | ri_child_user_time | |
| uint64_t | ri_child_system_time | |
| uint64_t | ri_child_pkg_idle_wkups | |
| uint64_t | ri_child_interrupt_wkups | |
| uint64_t | ri_child_pageins | |
| uint64_t | ri_child_elapsed_abstime | |
| uint64_t | ri_diskio_bytesread | |
| uint64_t | ri_diskio_byteswritten | |
| uint64_t | ri_cpu_time_qos_default | |
| uint64_t | ri_cpu_time_qos_maintenance | |
| uint64_t | ri_cpu_time_qos_background | |
| uint64_t | ri_cpu_time_qos_utility | |
| uint64_t | ri_cpu_time_qos_legacy | |
| uint64_t | ri_cpu_time_qos_user_initiated | |
| uint64_t | ri_cpu_time_qos_user_interactive | |
| uint64_t | ri_billed_system_time | |
| uint64_t | ri_serviced_system_time |
structrusage_info_v4
| uint8_t[16] | ri_uuid | |
| uint64_t | ri_user_time | |
| uint64_t | ri_system_time | |
| uint64_t | ri_pkg_idle_wkups | |
| uint64_t | ri_interrupt_wkups | |
| uint64_t | ri_pageins | |
| uint64_t | ri_wired_size | |
| uint64_t | ri_resident_size | |
| uint64_t | ri_phys_footprint | |
| uint64_t | ri_proc_start_abstime | |
| uint64_t | ri_proc_exit_abstime | |
| uint64_t | ri_child_user_time | |
| uint64_t | ri_child_system_time | |
| uint64_t | ri_child_pkg_idle_wkups | |
| uint64_t | ri_child_interrupt_wkups | |
| uint64_t | ri_child_pageins | |
| uint64_t | ri_child_elapsed_abstime | |
| uint64_t | ri_diskio_bytesread | |
| uint64_t | ri_diskio_byteswritten | |
| uint64_t | ri_cpu_time_qos_default | |
| uint64_t | ri_cpu_time_qos_maintenance | |
| uint64_t | ri_cpu_time_qos_background | |
| uint64_t | ri_cpu_time_qos_utility | |
| uint64_t | ri_cpu_time_qos_legacy | |
| uint64_t | ri_cpu_time_qos_user_initiated | |
| uint64_t | ri_cpu_time_qos_user_interactive | |
| uint64_t | ri_billed_system_time | |
| uint64_t | ri_serviced_system_time | |
| uint64_t | ri_logical_writes | |
| uint64_t | ri_lifetime_max_phys_footprint | |
| uint64_t | ri_instructions | |
| uint64_t | ri_cycles | |
| uint64_t | ri_billed_energy | |
| uint64_t | ri_serviced_energy | |
| uint64_t | ri_interval_max_phys_footprint | |
| uint64_t | ri_runnable_time |
structrusage_info_v5
| uint8_t[16] | ri_uuid | |
| uint64_t | ri_user_time | |
| uint64_t | ri_system_time | |
| uint64_t | ri_pkg_idle_wkups | |
| uint64_t | ri_interrupt_wkups | |
| uint64_t | ri_pageins | |
| uint64_t | ri_wired_size | |
| uint64_t | ri_resident_size | |
| uint64_t | ri_phys_footprint | |
| uint64_t | ri_proc_start_abstime | |
| uint64_t | ri_proc_exit_abstime | |
| uint64_t | ri_child_user_time | |
| uint64_t | ri_child_system_time | |
| uint64_t | ri_child_pkg_idle_wkups | |
| uint64_t | ri_child_interrupt_wkups | |
| uint64_t | ri_child_pageins | |
| uint64_t | ri_child_elapsed_abstime | |
| uint64_t | ri_diskio_bytesread | |
| uint64_t | ri_diskio_byteswritten | |
| uint64_t | ri_cpu_time_qos_default | |
| uint64_t | ri_cpu_time_qos_maintenance | |
| uint64_t | ri_cpu_time_qos_background | |
| uint64_t | ri_cpu_time_qos_utility | |
| uint64_t | ri_cpu_time_qos_legacy | |
| uint64_t | ri_cpu_time_qos_user_initiated | |
| uint64_t | ri_cpu_time_qos_user_interactive | |
| uint64_t | ri_billed_system_time | |
| uint64_t | ri_serviced_system_time | |
| uint64_t | ri_logical_writes | |
| uint64_t | ri_lifetime_max_phys_footprint | |
| uint64_t | ri_instructions | |
| uint64_t | ri_cycles | |
| uint64_t | ri_billed_energy | |
| uint64_t | ri_serviced_energy | |
| uint64_t | ri_interval_max_phys_footprint | |
| uint64_t | ri_runnable_time | |
| uint64_t | ri_flags |
structrusage_info_v6
| uint8_t[16] | ri_uuid | |
| uint64_t | ri_user_time | |
| uint64_t | ri_system_time | |
| uint64_t | ri_pkg_idle_wkups | |
| uint64_t | ri_interrupt_wkups | |
| uint64_t | ri_pageins | |
| uint64_t | ri_wired_size | |
| uint64_t | ri_resident_size | |
| uint64_t | ri_phys_footprint | |
| uint64_t | ri_proc_start_abstime | |
| uint64_t | ri_proc_exit_abstime | |
| uint64_t | ri_child_user_time | |
| uint64_t | ri_child_system_time | |
| uint64_t | ri_child_pkg_idle_wkups | |
| uint64_t | ri_child_interrupt_wkups | |
| uint64_t | ri_child_pageins | |
| uint64_t | ri_child_elapsed_abstime | |
| uint64_t | ri_diskio_bytesread | |
| uint64_t | ri_diskio_byteswritten | |
| uint64_t | ri_cpu_time_qos_default | |
| uint64_t | ri_cpu_time_qos_maintenance | |
| uint64_t | ri_cpu_time_qos_background | |
| uint64_t | ri_cpu_time_qos_utility | |
| uint64_t | ri_cpu_time_qos_legacy | |
| uint64_t | ri_cpu_time_qos_user_initiated | |
| uint64_t | ri_cpu_time_qos_user_interactive | |
| uint64_t | ri_billed_system_time | |
| uint64_t | ri_serviced_system_time | |
| uint64_t | ri_logical_writes | |
| uint64_t | ri_lifetime_max_phys_footprint | |
| uint64_t | ri_instructions | |
| uint64_t | ri_cycles | |
| uint64_t | ri_billed_energy | |
| uint64_t | ri_serviced_energy | |
| uint64_t | ri_interval_max_phys_footprint | |
| uint64_t | ri_runnable_time | |
| uint64_t | ri_flags | |
| uint64_t | ri_user_ptime | |
| uint64_t | ri_system_ptime | |
| uint64_t | ri_pinstructions | |
| uint64_t | ri_pcycles | |
| uint64_t | ri_energy_nj | |
| uint64_t | ri_penergy_nj | |
| uint64_t | ri_secure_time_in_system | |
| uint64_t | ri_secure_ptime_in_system | |
| uint64_t | ri_neural_footprint | |
| uint64_t | ri_lifetime_max_neural_footprint | |
| uint64_t | ri_interval_max_neural_footprint | |
| uint64_t[9] | ri_reserved |
typedefrusage_info_current
typedef struct rusage_info_v6 rusage_info_current
macroRLIM_INFINITY
Symbolic constants for resource limits; since all limits are representable
as a type rlim_t, we are permitted to define RLIM_SAVED_* in terms of
RLIM_INFINITY.
#define RLIM_INFINITY (((__uint64_t)1 << 63) - 1)
no limit
macroRLIMIT_CPU
Possible values of the first parameter to getrlimit()/setrlimit(), to
indicate for which resource the operation is being performed.
#define RLIMIT_CPU 0
cpu time per process
structrlimit
A structure representing a resource limit. The address of an instance
of this structure is the second parameter to getrlimit()/setrlimit().
| rlim_t | rlim_cur | current (soft) limit |
| rlim_t | rlim_max | maximum value for rlim_cur |
macroRLIMIT_WAKEUPS_MONITOR
proc_rlimit_control()
Resource limit flavors
#define RLIMIT_WAKEUPS_MONITOR 0x1
Configure the wakeups monitor.
macroRLIMIT_THREAD_CPULIMITS
#define RLIMIT_THREAD_CPULIMITS 0x3
Configure a blocking, per-thread, CPU limits.
macroRLIMIT_FOOTPRINT_INTERVAL
#define RLIMIT_FOOTPRINT_INTERVAL 0x4
Configure memory footprint interval tracking
macroWAKEMON_DISABLE
#define WAKEMON_DISABLE 0x02
macroWAKEMON_GET_PARAMS
#define WAKEMON_GET_PARAMS 0x04
macroWAKEMON_SET_DEFAULTS
#define WAKEMON_SET_DEFAULTS 0x08
macroWAKEMON_MAKE_FATAL
#define WAKEMON_MAKE_FATAL 0x10
Configure the task so that violations are fatal.
macroFOOTPRINT_INTERVAL_RESET
Flags for memory footprint interval tracking.
#define FOOTPRINT_INTERVAL_RESET 0x1
Reset the footprint interval counter to zero
structproc_rlimit_control_wakeupmon
| uint32_t | wm_flags | |
| int32_t | wm_rate |
macroIOPOL_TYPE_VFS_ATIME_UPDATES
#define IOPOL_TYPE_VFS_ATIME_UPDATES 2
macroIOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES
#define IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES 3
macroIOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME
#define IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME 4
macroIOPOL_TYPE_VFS_TRIGGER_RESOLVE
#define IOPOL_TYPE_VFS_TRIGGER_RESOLVE 5
macroIOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION
#define IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION 6
macroIOPOL_TYPE_VFS_IGNORE_PERMISSIONS
#define IOPOL_TYPE_VFS_IGNORE_PERMISSIONS 7
macroIOPOL_TYPE_VFS_SKIP_MTIME_UPDATE
#define IOPOL_TYPE_VFS_SKIP_MTIME_UPDATE 8
macroIOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES
#define IOPOL_TYPE_VFS_ALLOW_LOW_SPACE_WRITES 9
macroIOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY
#define IOPOL_TYPE_VFS_DISALLOW_RW_FOR_O_EVTONLY 10
macroIOPOL_TYPE_VFS_ENTITLED_RESERVE_ACCESS
#define IOPOL_TYPE_VFS_ENTITLED_RESERVE_ACCESS 14
macroIOPOL_SCOPE_THREAD
#define IOPOL_SCOPE_THREAD 1
macroIOPOL_SCOPE_DARWIN_BG
#define IOPOL_SCOPE_DARWIN_BG 2
macroIOPOL_IMPORTANT
#define IOPOL_IMPORTANT 1
macroIOPOL_PASSIVE
#define IOPOL_PASSIVE 2
macroIOPOL_THROTTLE
#define IOPOL_THROTTLE 3
macroIOPOL_UTILITY
#define IOPOL_UTILITY 4
macroIOPOL_STANDARD
#define IOPOL_STANDARD 5
macroIOPOL_NORMAL
#define IOPOL_NORMAL IOPOL_IMPORTANT
macroIOPOL_ATIME_UPDATES_DEFAULT
#define IOPOL_ATIME_UPDATES_DEFAULT 0
macroIOPOL_ATIME_UPDATES_OFF
#define IOPOL_ATIME_UPDATES_OFF 1
macroIOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT
#define IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT 0
macroIOPOL_MATERIALIZE_DATALESS_FILES_OFF
#define IOPOL_MATERIALIZE_DATALESS_FILES_OFF 1
macroIOPOL_MATERIALIZE_DATALESS_FILES_ON
#define IOPOL_MATERIALIZE_DATALESS_FILES_ON 2
macroIOPOL_MATERIALIZE_DATALESS_FILES_ORIG
#define IOPOL_MATERIALIZE_DATALESS_FILES_ORIG 4
macroIOPOL_MATERIALIZE_DATALESS_FILES_BASIC_MASK
#define IOPOL_MATERIALIZE_DATALESS_FILES_BASIC_MASK 3
macroIOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT
#define IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT 0
macroIOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME
#define IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME 1
macroIOPOL_VFS_TRIGGER_RESOLVE_DEFAULT
#define IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT 0
macroIOPOL_VFS_TRIGGER_RESOLVE_OFF
#define IOPOL_VFS_TRIGGER_RESOLVE_OFF 1
macroIOPOL_VFS_CONTENT_PROTECTION_DEFAULT
#define IOPOL_VFS_CONTENT_PROTECTION_DEFAULT 0
macroIOPOL_VFS_CONTENT_PROTECTION_IGNORE
#define IOPOL_VFS_CONTENT_PROTECTION_IGNORE 1
macroIOPOL_VFS_IGNORE_PERMISSIONS_OFF
#define IOPOL_VFS_IGNORE_PERMISSIONS_OFF 0
macroIOPOL_VFS_IGNORE_PERMISSIONS_ON
#define IOPOL_VFS_IGNORE_PERMISSIONS_ON 1
macroIOPOL_VFS_SKIP_MTIME_UPDATE_OFF
#define IOPOL_VFS_SKIP_MTIME_UPDATE_OFF 0
macroIOPOL_VFS_SKIP_MTIME_UPDATE_ON
#define IOPOL_VFS_SKIP_MTIME_UPDATE_ON 1
macroIOPOL_VFS_SKIP_MTIME_UPDATE_IGNORE
#define IOPOL_VFS_SKIP_MTIME_UPDATE_IGNORE 2
macroIOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF
#define IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_OFF 0
macroIOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON
#define IOPOL_VFS_ALLOW_LOW_SPACE_WRITES_ON 1
macroIOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT
#define IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_DEFAULT 0
macroIOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON
#define IOPOL_VFS_DISALLOW_RW_FOR_O_EVTONLY_ON 1
macroIOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT
#define IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_DEFAULT 0
macroIOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON
#define IOPOL_VFS_NOCACHE_WRITE_FS_BLKSIZE_ON 1
macroIOPOL_VFS_ENTITLED_RESERVE_ACCESS_OFF
#define IOPOL_VFS_ENTITLED_RESERVE_ACCESS_OFF 0
macroIOPOL_VFS_ENTITLED_RESERVE_ACCESS_ON
#define IOPOL_VFS_ENTITLED_RESERVE_ACCESS_ON 1
functiongetpriority
int getpriority(int, id_t)
man page · June 4, 1993
getpriority(2) — get/set program scheduling priorityfunctiongetiopolicy_np
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int getiopolicy_np(int, int)functiongetrlimit
__DARWIN_ALIAS(getrlimit) int getrlimit(int, struct rlimit *)
man page · June 4, 1993
getrlimit(2) — control maximum system resource consumptionfunctiongetrusage
int getrusage(int, struct rusage *)
man page · June 4, 1993
getrusage(2) — get information about resource utilizationfunctionsetpriority
int setpriority(int, id_t, int)
man page · June 4, 1993
setpriority(2) — get/set program scheduling priorityfunctionsetiopolicy_np
__OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
int setiopolicy_np(int, int, int)functionsetrlimit
__DARWIN_ALIAS(setrlimit) int setrlimit(int, const struct rlimit *)
man page · June 4, 1993
setrlimit(2) — control maximum system resource consumption