1 /* Copyright (C) 1992, 1994 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
26 /* Get the system-dependent definitions of RLIM_*. */
27 #include <resourcebits.h>
31 /* The current (soft) limit. */
37 /* Value used to indicate that there is no limit. */
38 #define RLIM_INFINITY 0x7fffffff
40 /* Put the soft and hard limits for RESOURCE in *RLIMITS.
41 Returns 0 if successful, -1 if not (and sets errno). */
42 int getrlimit
__P ((enum __rlimit_resource __resource
,
43 struct rlimit
* __rlimits
));
45 /* Set the soft and hard limits for RESOURCE to *RLIMITS.
46 Only the super-user can increase hard limits.
47 Return 0 if successful, -1 if not (and sets errno). */
48 int setrlimit
__P ((enum __rlimit_resource __resource
,
49 struct rlimit
* __rlimits
));
52 /* Whose usage statistics do you want? */
54 /* The macro definitions are necessary because some programs want
55 to test for operating system features with #ifdef RUSAGE_SELF.
56 In ANSI C the reflexive definition is a no-op. */
58 /* The calling process. */
60 #define RUSAGE_SELF RUSAGE_SELF
61 /* All of its terminated child processes. */
63 #define RUSAGE_CHILDREN RUSAGE_CHILDREN
66 #include <sys/time.h> /* For `struct timeval'. */
68 /* Structure which says how much of each resource has been used. */
71 /* Total amount of user time used. */
72 struct timeval ru_utime
;
73 /* Total amount of system time used. */
74 struct timeval ru_stime
;
75 /* Maximum resident set size (in kilobytes). */
77 /* Amount of sharing of text segment memory
78 with other processes (kilobyte-seconds). */
80 /* Amount of data segment memory used (kilobyte-seconds). */
82 /* Amount of stack memory used (kilobyte-seconds). */
84 /* Number of soft page faults (i.e. those serviced by reclaiming
85 a page from the list of pages awaiting reallocation. */
87 /* Number of hard page faults (i.e. those that required I/O). */
89 /* Number of times a process was swapped out of physical memory. */
91 /* Number of input operations via the file system. Note: This
92 and `ru_oublock' do not include operations with the cache. */
94 /* Number of output operations via the file system. */
96 /* Number of IPC messages sent. */
98 /* Number of IPC messages received. */
100 /* Number of signals delivered. */
102 /* Number of voluntary context switches, i.e. because the process
103 gave up the process before it had to (usually to wait for some
104 resource to be available). */
106 /* Number of involuntary context switches, i.e. a higher priority process
107 became runnable or the current process used up its time slice. */
111 /* Return resource usage information on process indicated by WHO
112 and put it in *USAGE. Returns 0 for success, -1 for failure. */
113 int __getrusage
__P ((enum __rusage_who __who
, struct rusage
* __usage
));
114 int getrusage
__P ((enum __rusage_who __who
, struct rusage
* __usage
));
116 /* Function depends on CMD:
117 1 = Return the limit on the size of a file, in units of 512 bytes.
118 2 = Set the limit on the size of a file to NEWLIMIT. Only the
119 super-user can increase the limit.
120 3 = Return the maximum possible address of the data segment.
121 4 = Return the maximum number of files that the calling process can open.
122 Returns -1 on errors. */
123 long int __ulimit
__P ((int __cmd
, long int __newlimit
));
124 long int ulimit
__P ((int __cmd
, long int __newlimit
));
127 /* Priority limits. */
128 #define PRIO_MIN -20 /* Minimum priority a process can have. */
129 #define PRIO_MAX 20 /* Maximum priority a process can have. */
131 /* The type of the WHICH argument to `getpriority' and `setpriority',
132 indicating what flavor of entity the WHO argument specifies. */
133 enum __priority_which
135 PRIO_PROCESS
= 0, /* WHO is a process ID. */
136 PRIO_PGRP
= 1, /* WHO is a process group ID. */
137 PRIO_USER
= 2, /* WHO is a user ID. */
140 /* Return the highest priority of any process specified by WHICH and WHO
141 (see above); if WHO is zero, the current process, process group, or user
142 (as specified by WHO) is used. A lower priority number means higher
143 priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */
144 extern int getpriority
__P ((enum __priority_which __which
, int __who
));
146 /* Set the priority of all processes specified by WHICH and WHO (see above)
147 to PRIO. Returns 0 on success, -1 on errors. */
148 extern int setpriority
__P ((enum __priority_which __which
, int __who
,
154 #endif /* resource.h */