resource.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /* Bit values & structures for resource limits. Alpha/Linux version.
  2. Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2004, 2005
  3. Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef _SYS_RESOURCE_H
  17. # error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
  18. #endif
  19. #include <bits/types.h>
  20. /* Transmute defines to enumerations. The macro re-definitions are
  21. necessary because some programs want to test for operating system
  22. features with #ifdef RUSAGE_SELF. In ISO C the reflexive
  23. definition is a no-op. */
  24. /* Kinds of resource limit. */
  25. enum __rlimit_resource
  26. {
  27. /* Per-process CPU limit, in seconds. */
  28. RLIMIT_CPU = 0,
  29. #define RLIMIT_CPU RLIMIT_CPU
  30. /* Largest file that can be created, in bytes. */
  31. RLIMIT_FSIZE = 1,
  32. #define RLIMIT_FSIZE RLIMIT_FSIZE
  33. /* Maximum size of data segment, in bytes. */
  34. RLIMIT_DATA = 2,
  35. #define RLIMIT_DATA RLIMIT_DATA
  36. /* Maximum size of stack segment, in bytes. */
  37. RLIMIT_STACK = 3,
  38. #define RLIMIT_STACK RLIMIT_STACK
  39. /* Largest core file that can be created, in bytes. */
  40. RLIMIT_CORE = 4,
  41. #define RLIMIT_CORE RLIMIT_CORE
  42. /* Largest resident set size, in bytes.
  43. This affects swapping; processes that are exceeding their
  44. resident set size will be more likely to have physical memory
  45. taken from them. */
  46. __RLIMIT_RSS = 5,
  47. #define RLIMIT_RSS __RLIMIT_RSS
  48. /* Number of open files. */
  49. RLIMIT_NOFILE = 6,
  50. __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
  51. #define RLIMIT_NOFILE RLIMIT_NOFILE
  52. #define RLIMIT_OFILE __RLIMIT_OFILE
  53. /* Address space limit (?) */
  54. RLIMIT_AS = 7,
  55. #define RLIMIT_AS RLIMIT_AS
  56. /* Number of processes. */
  57. __RLIMIT_NPROC = 8,
  58. #define RLIMIT_NPROC __RLIMIT_NPROC
  59. /* Locked-in-memory address space. */
  60. __RLIMIT_MEMLOCK = 9,
  61. #define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
  62. /* Maximum number of file locks. */
  63. __RLIMIT_LOCKS = 10,
  64. #define RLIMIT_LOCKS __RLIMIT_LOCKS
  65. /* Maximum number of pending signals. */
  66. __RLIMIT_SIGPENDING = 11,
  67. #define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING
  68. /* Maximum bytes in POSIX message queues. */
  69. __RLIMIT_MSGQUEUE = 12,
  70. #define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE
  71. /* Maximum nice priority allowed to raise to.
  72. Nice levels 19 .. -20 correspond to 0 .. 39
  73. values of this resource limit. */
  74. __RLIMIT_NICE = 13,
  75. #define RLIMIT_NICE __RLIMIT_NICE
  76. /* Maximum realtime priority allowed for non-priviledged
  77. processes. */
  78. __RLIMIT_RTPRIO = 14,
  79. #define RLIMIT_RTPRIO __RLIMIT_RTPRIO
  80. /* Maximum CPU time in µs that a process scheduled under a real-time
  81. scheduling policy may consume without making a blocking system
  82. call before being forcibly descheduled. */
  83. __RLIMIT_RTTIME = 15,
  84. #define RLIMIT_RTTIME __RLIMIT_RTTIME
  85. __RLIMIT_NLIMITS = 16,
  86. __RLIM_NLIMITS = __RLIMIT_NLIMITS
  87. #define RLIMIT_NLIMITS __RLIMIT_NLIMITS
  88. #define RLIM_NLIMITS __RLIM_NLIMITS
  89. };
  90. /* Value to indicate that there is no limit. */
  91. #ifndef __USE_FILE_OFFSET64
  92. # define RLIM_INFINITY ((long int)(~0UL >> 1))
  93. #else
  94. # define RLIM_INFINITY 0x7fffffffffffffffLL
  95. #endif
  96. #ifdef __USE_LARGEFILE64
  97. # define RLIM64_INFINITY 0x7fffffffffffffffLL
  98. #endif
  99. /* We can represent all limits. */
  100. #define RLIM_SAVED_MAX RLIM_INFINITY
  101. #define RLIM_SAVED_CUR RLIM_INFINITY
  102. /* Type for resource quantity measurement. */
  103. #ifndef __USE_FILE_OFFSET64
  104. typedef __rlim_t rlim_t;
  105. #else
  106. typedef __rlim64_t rlim_t;
  107. #endif
  108. #ifdef __USE_LARGEFILE64
  109. typedef __rlim64_t rlim64_t;
  110. #endif
  111. struct rlimit
  112. {
  113. /* The current (soft) limit. */
  114. rlim_t rlim_cur;
  115. /* The hard limit. */
  116. rlim_t rlim_max;
  117. };
  118. #ifdef __USE_LARGEFILE64
  119. struct rlimit64
  120. {
  121. /* The current (soft) limit. */
  122. rlim64_t rlim_cur;
  123. /* The hard limit. */
  124. rlim64_t rlim_max;
  125. };
  126. #endif
  127. /* Whose usage statistics do you want? */
  128. enum __rusage_who
  129. {
  130. /* The calling process. */
  131. RUSAGE_SELF = 0,
  132. #define RUSAGE_SELF RUSAGE_SELF
  133. /* All of its terminated child processes. */
  134. RUSAGE_CHILDREN = -1
  135. #define RUSAGE_CHILDREN RUSAGE_CHILDREN
  136. #ifdef __USE_GNU
  137. ,
  138. /* The calling thread. */
  139. RUSAGE_THREAD = 1
  140. # define RUSAGE_THREAD RUSAGE_THREAD
  141. /* Name for the same functionality on Solaris. */
  142. # define RUSAGE_LWP RUSAGE_THREAD
  143. #endif
  144. };
  145. #define __need_timeval
  146. #include <bits/time.h> /* For `struct timeval'. */
  147. /* Structure which says how much of each resource has been used. */
  148. struct rusage
  149. {
  150. /* Total amount of user time used. */
  151. struct timeval ru_utime;
  152. /* Total amount of system time used. */
  153. struct timeval ru_stime;
  154. /* Maximum resident set size (in kilobytes). */
  155. long int ru_maxrss;
  156. /* Amount of sharing of text segment memory
  157. with other processes (kilobyte-seconds). */
  158. long int ru_ixrss;
  159. /* Amount of data segment memory used (kilobyte-seconds). */
  160. long int ru_idrss;
  161. /* Amount of stack memory used (kilobyte-seconds). */
  162. long int ru_isrss;
  163. /* Number of soft page faults (i.e. those serviced by reclaiming
  164. a page from the list of pages awaiting reallocation. */
  165. long int ru_minflt;
  166. /* Number of hard page faults (i.e. those that required I/O). */
  167. long int ru_majflt;
  168. /* Number of times a process was swapped out of physical memory. */
  169. long int ru_nswap;
  170. /* Number of input operations via the file system. Note: This
  171. and `ru_oublock' do not include operations with the cache. */
  172. long int ru_inblock;
  173. /* Number of output operations via the file system. */
  174. long int ru_oublock;
  175. /* Number of IPC messages sent. */
  176. long int ru_msgsnd;
  177. /* Number of IPC messages received. */
  178. long int ru_msgrcv;
  179. /* Number of signals delivered. */
  180. long int ru_nsignals;
  181. /* Number of voluntary context switches, i.e. because the process
  182. gave up the process before it had to (usually to wait for some
  183. resource to be available). */
  184. long int ru_nvcsw;
  185. /* Number of involuntary context switches, i.e. a higher priority process
  186. became runnable or the current process used up its time slice. */
  187. long int ru_nivcsw;
  188. };
  189. /* Priority limits. */
  190. #define PRIO_MIN -20 /* Minimum priority a process can have. */
  191. #define PRIO_MAX 20 /* Maximum priority a process can have. */
  192. /* The type of the WHICH argument to `getpriority' and `setpriority',
  193. indicating what flavor of entity the WHO argument specifies. */
  194. enum __priority_which
  195. {
  196. PRIO_PROCESS = 0, /* WHO is a process ID. */
  197. #define PRIO_PROCESS PRIO_PROCESS
  198. PRIO_PGRP = 1, /* WHO is a process group ID. */
  199. #define PRIO_PGRP PRIO_PGRP
  200. PRIO_USER = 2 /* WHO is a user ID. */
  201. #define PRIO_USER PRIO_USER
  202. };