1 /* Copyright (C) 1992 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
19 #ifndef _SYS_RESOURCE_H
21 #define _SYS_RESOURCE_H 1
29 /* Kinds of resource limit. */
30 enum __rlimit_resource
32 /* Per-process CPU limit, in seconds. */
34 /* Largest file that can be created, in bytes. */
36 /* Maximum size of data segment, in bytes. */
38 /* Maximum size of stack segment, in bytes. */
40 /* Largest core file that can be created, in bytes. */
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
47 /* Locked-in-memory address space. */
49 /* Number of processes, */
51 /* Number of open files. */
59 /* The current (soft) limit. */
65 /* Value used to indicate that there is no limit. */
66 #define RLIM_INFINITY 0x7fffffff
68 /* Put the soft and hard limits for RESOURCE in *RLIMITS.
69 Returns 0 if successful, -1 if not (and sets errno). */
70 int getrlimit __P ((enum __rlimit_resource __resource,
71 struct rlimit * __rlimits));
73 /* Set the soft and hard limits for RESOURCE to *RLIMITS.
74 Only the super-user can increase hard limits.
75 Return 0 if successful, -1 if not (and sets errno). */
76 int setrlimit __P ((enum __rlimit_resource __resource,
77 struct rlimit * __rlimits));
80 /* Whose usage statistics do you want? */
83 /* The calling process. */
85 /* All of its terminated child processes. */
89 #include <sys/time.h> /* For `struct timeval'. */
91 /* Structure which says how much of each resource has been used. */
94 /* Total amount of user time used. */
95 struct timeval ru_utime;
96 /* Total amount of system time used. */
97 struct timeval ru_stime;
98 /* Maximum resident set size (in kilobytes). */
100 /* Amount of sharing of text segment memory
101 with other processes (kilobyte-seconds). */
103 /* Amount of data segment memory used (kilobyte-seconds). */
105 /* Amount of stack memory used (kilobyte-seconds). */
107 /* Number of soft page faults (i.e. those serviced by reclaiming
108 a page from the list of pages awaiting reallocation. */
110 /* Number of hard page faults (i.e. those that required I/O). */
112 /* Number of times a process was swapped out of physical memory. */
114 /* Number of input operations via the file system. Note: This
115 and `ru_oublock' do not include operations with the cache. */
117 /* Number of output operations via the file system. */
119 /* Number of IPC messages sent. */
121 /* Number of IPC messages received. */
123 /* Number of signals delivered. */
125 /* Number of voluntary context switches, i.e. because the process
126 gave up the process before it had to (usually to wait for some
127 resource to be available). */
129 /* Number of involuntary context switches, i.e. a higher priority process
130 became runnable or the current process used up its time slice. */
134 /* Return resource usage information on process indicated by WHO
135 and put it in *USAGE. Returns 0 for success, -1 for failure. */
136 int __getrusage __P ((enum __rusage_who __who, struct rusage * __usage));
137 int getrusage __P ((enum __rusage_who __who, struct rusage * __usage));
139 /* Function depends on CMD:
140 1 = Return the limit on the size of a file, in units of 512 bytes.
141 2 = Set the limit on the size of a file to NEWLIMIT. Only the
142 super-user can increase the limit.
143 3 = Return the maximum possible address of the data segment.
144 4 = Return the maximum number of files that the calling process can open.
145 Returns -1 on errors. */
146 long int __ulimit __P ((int __cmd, long int __newlimit));
147 long int ulimit __P ((int __cmd, long int __newlimit));
150 /* Priority limits. */
151 #define PRIO_MIN -20 /* Minimum priority a process can have. */
152 #define PRIO_MAX 20 /* Maximum priority a process can have. */
154 /* The type of the WHICH argument to `getpriority' and `setpriority',
155 indicating what flavor of entity the WHO argument specifies. */
156 enum __priority_which
158 PRIO_PROCESS = 0, /* WHO is a process ID. */
159 PRIO_PGRP = 1, /* WHO is a process group ID. */
160 PRIO_USER = 2, /* WHO is a user ID. */
163 /* Return the highest priority of any process specified by WHICH and WHO
164 (see above); if WHO is zero, the current process, process group, or user
165 (as specified by WHO) is used. A lower priority number means higher
166 priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */
167 extern int getpriority __P ((enum __priority_which __which, int __who));
169 /* Set the priority of all processes specified by WHICH and WHO (see above)
170 to PRIO. Returns 0 on success, -1 on errors. */
171 extern int setpriority __P ((enum __priority_which __which, int __who,
177 #endif /* resource.h */