1 /* Copyright (C) 1991 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
19 #ifndef _SYS_RESOURCE_H
21 #define _SYS_RESOURCE_H 1
27 /* Kinds of resource limit. */
28 enum __rlimit_resource
30 /* Per-process CPU limit, in seconds. */
32 /* Largest file that can be created, in bytes. */
34 /* Maximum size of data segment, in bytes. */
36 /* Maximum size of stack segment, in bytes. */
38 /* Largest core file that can be created, in bytes. */
40 /* Largest resident set size, in bytes.
41 This affects swapping; processes that are exceeding their
42 resident set size will be more likely to have physical memory
51 /* The current (soft) limit. */
57 /* Value used to indicate that there is no limit. */
58 #define RLIM_INFINITY 0x7fffffff
60 /* Put the soft and hard limits for RESOURCE in *RLIMITS.
61 Returns 0 if successful, -1 if not (and sets errno). */
62 int EXFUN(getrlimit, (enum __rlimit_resource __resource,
63 struct rlimit *__rlimits));
65 /* Set the soft and hard limits for RESOURCE to *RLIMITS.
66 Only the super-user can increase hard limits.
67 Return 0 if successful, -1 if not (and sets errno). */
68 int EXFUN(setrlimit, (enum __rlimit_resource __resource,
69 struct rlimit *__rlimits));
72 /* Whose usage statistics do you want? */
75 /* The calling process. */
77 /* All of its terminated child processes. */
81 /* Structure which says how much of each resource has been used. */
84 /* Total amount of user time used. */
85 struct __timeval ru_utime;
86 /* Total amount of system time used. */
87 struct __timeval ru_stime;
88 /* Maximum resident set size (in kilobytes). */
90 /* Amount of sharing of text segment memory
91 with other processes (kilobyte-seconds). */
93 /* Amount of data segment memory used (kilobyte-seconds). */
95 /* Amount of stack memory used (kilobyte-seconds). */
97 /* Number of soft page faults (i.e. those serviced by reclaiming
98 a page from the list of pages awaiting reallocation. */
100 /* Number of hard page faults (i.e. those that required I/O). */
102 /* Number of times a process was swapped out of physical memory. */
104 /* Number of input operations via the file system. Note: This
105 and `ru_outblock' do not include operations with the cache. */
107 /* Number of output operations via the file system. */
109 /* Number of IPC messages sent. */
111 /* Number of IPC messages received. */
113 /* Number of signals delivered. */
115 /* Number of voluntary context switches, i.e. because the process
116 gave up the process before it had to (usually to wait for some
117 resource to be available). */
119 /* Number of involuntary context switches, i.e. a higher priority process
120 became runnable or the current process used up its time slice. */
124 /* Return resource usage information on process indicated by WHO
125 and put it in *USAGE. Returns 0 for success, -1 for failure. */
126 int EXFUN(__getrusage, (enum __rusage_who __who, struct rusage *__usage));
127 int EXFUN(getrusage, (enum __rusage_who __who, struct rusage *__usage));
130 #define getrusage(who, usage) __getrusage((who), (usage))
131 #endif /* Optimizing. */
133 /* Function depends on CMD:
134 1 = Return the limit on the size of a file, in units of 512 bytes.
135 2 = Set the limit on the size of a file to NEWLIMIT. Only the
136 super-user can increase the limit.
137 3 = Return the maximum possible address of the data segment.
138 4 = Return the maximum number of files that the calling process can open.
139 Returns -1 on errors. */
140 long int EXFUN(__ulimit, (int __cmd, long int __newlimit));
141 long int EXFUN(ulimit, (int __cmd, long int __newlimit));
144 #define ulimit(cmd, newlimit) __ulimit((cmd), (newlimit))
145 #endif /* Optimizing. */
148 /* Priority limits. */
149 #define PRIO_MIN -20 /* Minimum priority a process can have. */
150 #define PRIO_MAX 20 /* Maximum priority a process can have. */
152 /* The type of the WHICH argument to `getpriority' and `setpriority',
153 indicating what flavor of entity the WHO argument specifies. */
154 enum __priority_which
156 PRIO_PROCESS = 0, /* WHO is a process ID. */
157 PRIO_PGRP = 1, /* WHO is a process group ID. */
158 PRIO_USER = 2, /* WHO is a user ID. */
161 /* Return the highest priority of any process specified by WHICH and WHO
162 (see above); if WHO is zero, the current process, process group, or user
163 (as specified by WHO) is used. A lower priority number means higher
164 priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */
165 extern int EXFUN(getpriority, (enum __priority_which __which, int __who));
167 /* Set the priority of all processes specified by WHICH and WHO (see above)
168 to PRIO. Returns 0 on success, -1 on errors. */
169 extern int EXFUN(setpriority, (enum __priority_which __which, int __who,
173 #endif /* resource.h */