#include <sys/resource.h>

sys/resource.h

includes: sys/appleapiopts.h, sys/cdefs.h, sys/_types.h, stdint.h, Availability.h, sys/_types/_timeval.h, sys/_types/_id_t.h
96 macros · 10 structs · 7 functions · 3 typedefs

typedefrlim_t

Resource limit type (low 63 bits, excluding the sign bit)
typedef __uint64_t rlim_t

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_PGRP

#define PRIO_PGRP 1
Second argument is a GID

macroPRIO_USER

#define PRIO_USER 2
Second argument is a UID

macroPRIO_DARWIN_THREAD

#define PRIO_DARWIN_THREAD 3
Second argument is always 0 (current thread)

macroPRIO_DARWIN_PROCESS

#define PRIO_DARWIN_PROCESS 4
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

macroRUSAGE_CHILDREN

#define RUSAGE_CHILDREN -1
Current process' children

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.
size 144, align 8
struct timevalru_utimeuser time used (PL)
struct timevalru_stimesystem time used (PL)
longru_maxrssInformational 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)
longru_ixrssintegral shared memory size (NU)
longru_idrssintegral unshared data (NU)
longru_isrssintegral unshared stack (NU)
longru_minfltpage reclaims (NU)
longru_majfltpage faults (NU)
longru_nswapswaps (NU)
longru_inblockblock input operations (atomic)
longru_oublockblock output operations (atomic)
longru_msgsndmessages sent (atomic)
longru_msgrcvmessages received (atomic)
longru_nsignalssignals received (atomic)
longru_nvcswvoluntary context switches (atomic)
longru_nivcswinvoluntary "

macroru_first

#define ru_first ru_ixrss
internal: ruadd() range start

macroru_last

#define ru_last ru_nivcsw
internal: ruadd() range end

macroRUSAGE_INFO_V0

Flavors for proc_pid_rusage().
#define RUSAGE_INFO_V0 0

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

size 96, align 8
uint8_t[16]ri_uuid
uint64_tri_user_time
uint64_tri_system_time
uint64_tri_pkg_idle_wkups
uint64_tri_interrupt_wkups
uint64_tri_pageins
uint64_tri_wired_size
uint64_tri_resident_size
uint64_tri_phys_footprint
uint64_tri_proc_start_abstime
uint64_tri_proc_exit_abstime

structrusage_info_v1

size 144, align 8
uint8_t[16]ri_uuid
uint64_tri_user_time
uint64_tri_system_time
uint64_tri_pkg_idle_wkups
uint64_tri_interrupt_wkups
uint64_tri_pageins
uint64_tri_wired_size
uint64_tri_resident_size
uint64_tri_phys_footprint
uint64_tri_proc_start_abstime
uint64_tri_proc_exit_abstime
uint64_tri_child_user_time
uint64_tri_child_system_time
uint64_tri_child_pkg_idle_wkups
uint64_tri_child_interrupt_wkups
uint64_tri_child_pageins
uint64_tri_child_elapsed_abstime

structrusage_info_v2

size 160, align 8
uint8_t[16]ri_uuid
uint64_tri_user_time
uint64_tri_system_time
uint64_tri_pkg_idle_wkups
uint64_tri_interrupt_wkups
uint64_tri_pageins
uint64_tri_wired_size
uint64_tri_resident_size
uint64_tri_phys_footprint
uint64_tri_proc_start_abstime
uint64_tri_proc_exit_abstime
uint64_tri_child_user_time
uint64_tri_child_system_time
uint64_tri_child_pkg_idle_wkups
uint64_tri_child_interrupt_wkups
uint64_tri_child_pageins
uint64_tri_child_elapsed_abstime
uint64_tri_diskio_bytesread
uint64_tri_diskio_byteswritten

structrusage_info_v3

size 232, align 8
uint8_t[16]ri_uuid
uint64_tri_user_time
uint64_tri_system_time
uint64_tri_pkg_idle_wkups
uint64_tri_interrupt_wkups
uint64_tri_pageins
uint64_tri_wired_size
uint64_tri_resident_size
uint64_tri_phys_footprint
uint64_tri_proc_start_abstime
uint64_tri_proc_exit_abstime
uint64_tri_child_user_time
uint64_tri_child_system_time
uint64_tri_child_pkg_idle_wkups
uint64_tri_child_interrupt_wkups
uint64_tri_child_pageins
uint64_tri_child_elapsed_abstime
uint64_tri_diskio_bytesread
uint64_tri_diskio_byteswritten
uint64_tri_cpu_time_qos_default
uint64_tri_cpu_time_qos_maintenance
uint64_tri_cpu_time_qos_background
uint64_tri_cpu_time_qos_utility
uint64_tri_cpu_time_qos_legacy
uint64_tri_cpu_time_qos_user_initiated
uint64_tri_cpu_time_qos_user_interactive
uint64_tri_billed_system_time
uint64_tri_serviced_system_time

structrusage_info_v4

size 296, align 8
uint8_t[16]ri_uuid
uint64_tri_user_time
uint64_tri_system_time
uint64_tri_pkg_idle_wkups
uint64_tri_interrupt_wkups
uint64_tri_pageins
uint64_tri_wired_size
uint64_tri_resident_size
uint64_tri_phys_footprint
uint64_tri_proc_start_abstime
uint64_tri_proc_exit_abstime
uint64_tri_child_user_time
uint64_tri_child_system_time
uint64_tri_child_pkg_idle_wkups
uint64_tri_child_interrupt_wkups
uint64_tri_child_pageins
uint64_tri_child_elapsed_abstime
uint64_tri_diskio_bytesread
uint64_tri_diskio_byteswritten
uint64_tri_cpu_time_qos_default
uint64_tri_cpu_time_qos_maintenance
uint64_tri_cpu_time_qos_background
uint64_tri_cpu_time_qos_utility
uint64_tri_cpu_time_qos_legacy
uint64_tri_cpu_time_qos_user_initiated
uint64_tri_cpu_time_qos_user_interactive
uint64_tri_billed_system_time
uint64_tri_serviced_system_time
uint64_tri_logical_writes
uint64_tri_lifetime_max_phys_footprint
uint64_tri_instructions
uint64_tri_cycles
uint64_tri_billed_energy
uint64_tri_serviced_energy
uint64_tri_interval_max_phys_footprint
uint64_tri_runnable_time

structrusage_info_v5

size 304, align 8
uint8_t[16]ri_uuid
uint64_tri_user_time
uint64_tri_system_time
uint64_tri_pkg_idle_wkups
uint64_tri_interrupt_wkups
uint64_tri_pageins
uint64_tri_wired_size
uint64_tri_resident_size
uint64_tri_phys_footprint
uint64_tri_proc_start_abstime
uint64_tri_proc_exit_abstime
uint64_tri_child_user_time
uint64_tri_child_system_time
uint64_tri_child_pkg_idle_wkups
uint64_tri_child_interrupt_wkups
uint64_tri_child_pageins
uint64_tri_child_elapsed_abstime
uint64_tri_diskio_bytesread
uint64_tri_diskio_byteswritten
uint64_tri_cpu_time_qos_default
uint64_tri_cpu_time_qos_maintenance
uint64_tri_cpu_time_qos_background
uint64_tri_cpu_time_qos_utility
uint64_tri_cpu_time_qos_legacy
uint64_tri_cpu_time_qos_user_initiated
uint64_tri_cpu_time_qos_user_interactive
uint64_tri_billed_system_time
uint64_tri_serviced_system_time
uint64_tri_logical_writes
uint64_tri_lifetime_max_phys_footprint
uint64_tri_instructions
uint64_tri_cycles
uint64_tri_billed_energy
uint64_tri_serviced_energy
uint64_tri_interval_max_phys_footprint
uint64_tri_runnable_time
uint64_tri_flags

structrusage_info_v6

size 464, align 8
uint8_t[16]ri_uuid
uint64_tri_user_time
uint64_tri_system_time
uint64_tri_pkg_idle_wkups
uint64_tri_interrupt_wkups
uint64_tri_pageins
uint64_tri_wired_size
uint64_tri_resident_size
uint64_tri_phys_footprint
uint64_tri_proc_start_abstime
uint64_tri_proc_exit_abstime
uint64_tri_child_user_time
uint64_tri_child_system_time
uint64_tri_child_pkg_idle_wkups
uint64_tri_child_interrupt_wkups
uint64_tri_child_pageins
uint64_tri_child_elapsed_abstime
uint64_tri_diskio_bytesread
uint64_tri_diskio_byteswritten
uint64_tri_cpu_time_qos_default
uint64_tri_cpu_time_qos_maintenance
uint64_tri_cpu_time_qos_background
uint64_tri_cpu_time_qos_utility
uint64_tri_cpu_time_qos_legacy
uint64_tri_cpu_time_qos_user_initiated
uint64_tri_cpu_time_qos_user_interactive
uint64_tri_billed_system_time
uint64_tri_serviced_system_time
uint64_tri_logical_writes
uint64_tri_lifetime_max_phys_footprint
uint64_tri_instructions
uint64_tri_cycles
uint64_tri_billed_energy
uint64_tri_serviced_energy
uint64_tri_interval_max_phys_footprint
uint64_tri_runnable_time
uint64_tri_flags
uint64_tri_user_ptime
uint64_tri_system_ptime
uint64_tri_pinstructions
uint64_tri_pcycles
uint64_tri_energy_nj
uint64_tri_penergy_nj
uint64_tri_secure_time_in_system
uint64_tri_secure_ptime_in_system
uint64_tri_neural_footprint
uint64_tri_lifetime_max_neural_footprint
uint64_tri_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

macroRLIM_SAVED_MAX

#define RLIM_SAVED_MAX RLIM_INFINITY
Unrepresentable hard limit

macroRLIM_SAVED_CUR

#define RLIM_SAVED_CUR RLIM_INFINITY
Unrepresentable soft 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

macroRLIMIT_FSIZE

#define RLIMIT_FSIZE 1
file size

macroRLIMIT_DATA

#define RLIMIT_DATA 2
data segment size

macroRLIMIT_STACK

#define RLIMIT_STACK 3
stack size

macroRLIMIT_CORE

#define RLIMIT_CORE 4
core file size

macroRLIMIT_AS

#define RLIMIT_AS 5
address space (resident set size)

macroRLIMIT_RSS

#define RLIMIT_RSS RLIMIT_AS
source compatibility alias

macroRLIMIT_MEMLOCK

#define RLIMIT_MEMLOCK 6
locked-in-memory address space

macroRLIMIT_NPROC

#define RLIMIT_NPROC 7
number of processes

macroRLIMIT_NOFILE

#define RLIMIT_NOFILE 8
number of open files

macroRLIM_NLIMITS

#define RLIM_NLIMITS 9
total number of resource limits

macro_RLIMIT_POSIX_FLAG

#define _RLIMIT_POSIX_FLAG 0x1000
Set bit for strict POSIX

structrlimit

A structure representing a resource limit. The address of an instance of this structure is the second parameter to getrlimit()/setrlimit().
size 16, align 8
rlim_trlim_curcurrent (soft) limit
rlim_trlim_maxmaximum value for rlim_cur

macroRLIMIT_WAKEUPS_MONITOR

proc_rlimit_control() Resource limit flavors
#define RLIMIT_WAKEUPS_MONITOR 0x1
Configure the wakeups monitor.

macroRLIMIT_CPU_USAGE_MONITOR

#define RLIMIT_CPU_USAGE_MONITOR 0x2
Configure the CPU usage 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_ENABLE

Flags for wakeups monitor control.
#define WAKEMON_ENABLE 0x01

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.

macroCPUMON_MAKE_FATAL

Flags for CPU usage monitor control.
#define CPUMON_MAKE_FATAL 0x1000

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

size 8, align 4
uint32_twm_flags
int32_twm_rate

macroIOPOL_TYPE_DISK

I/O type
#define IOPOL_TYPE_DISK 0

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_PROCESS

scope
#define IOPOL_SCOPE_PROCESS 0

macroIOPOL_SCOPE_THREAD

#define IOPOL_SCOPE_THREAD 1

macroIOPOL_SCOPE_DARWIN_BG

#define IOPOL_SCOPE_DARWIN_BG 2

macroIOPOL_DEFAULT

I/O Priority
#define IOPOL_DEFAULT 0

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_APPLICATION

compatibility with older names
#define IOPOL_APPLICATION IOPOL_STANDARD

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 priority

functiongetiopolicy_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 consumption

functiongetrusage

int getrusage(int, struct rusage *)
man page · June 4, 1993
getrusage(2) — get information about resource utilization

functionsetpriority

int setpriority(int, id_t, int)
man page · June 4, 1993
setpriority(2) — get/set program scheduling priority

functionsetiopolicy_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