Back to index

glibc  2.9
resource.h
Go to the documentation of this file.
00001 /* Bit values & structures for resource limits.  Linux version.
00002    Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2004, 2005
00003    Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef _SYS_RESOURCE_H
00022 # error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
00023 #endif
00024 
00025 #include <bits/types.h>
00026 
00027 /* Transmute defines to enumerations.  The macro re-definitions are
00028    necessary because some programs want to test for operating system
00029    features with #ifdef RUSAGE_SELF.  In ISO C the reflexive
00030    definition is a no-op.  */
00031 
00032 /* Kinds of resource limit.  */
00033 enum __rlimit_resource
00034 {
00035   /* Per-process CPU limit, in seconds.  */
00036   RLIMIT_CPU = 0,
00037 #define RLIMIT_CPU RLIMIT_CPU
00038 
00039   /* Largest file that can be created, in bytes.  */
00040   RLIMIT_FSIZE = 1,
00041 #define       RLIMIT_FSIZE RLIMIT_FSIZE
00042 
00043   /* Maximum size of data segment, in bytes.  */
00044   RLIMIT_DATA = 2,
00045 #define       RLIMIT_DATA RLIMIT_DATA
00046 
00047   /* Maximum size of stack segment, in bytes.  */
00048   RLIMIT_STACK = 3,
00049 #define       RLIMIT_STACK RLIMIT_STACK
00050 
00051   /* Largest core file that can be created, in bytes.  */
00052   RLIMIT_CORE = 4,
00053 #define       RLIMIT_CORE RLIMIT_CORE
00054 
00055   /* Largest resident set size, in bytes.
00056      This affects swapping; processes that are exceeding their
00057      resident set size will be more likely to have physical memory
00058      taken from them.  */
00059   __RLIMIT_RSS = 5,
00060 #define       RLIMIT_RSS __RLIMIT_RSS
00061 
00062   /* Number of open files.  */
00063   RLIMIT_NOFILE = 7,
00064   __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same.  */
00065 #define RLIMIT_NOFILE RLIMIT_NOFILE
00066 #define RLIMIT_OFILE __RLIMIT_OFILE
00067 
00068   /* Address space limit.  */
00069   RLIMIT_AS = 9,
00070 #define RLIMIT_AS RLIMIT_AS
00071 
00072   /* Number of processes.  */
00073   __RLIMIT_NPROC = 6,
00074 #define RLIMIT_NPROC __RLIMIT_NPROC
00075 
00076   /* Locked-in-memory address space.  */
00077   __RLIMIT_MEMLOCK = 8,
00078 #define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
00079 
00080   /* Maximum number of file locks.  */
00081   __RLIMIT_LOCKS = 10,
00082 #define RLIMIT_LOCKS __RLIMIT_LOCKS
00083 
00084   /* Maximum number of pending signals.  */
00085   __RLIMIT_SIGPENDING = 11,
00086 #define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING
00087 
00088   /* Maximum bytes in POSIX message queues.  */
00089   __RLIMIT_MSGQUEUE = 12,
00090 #define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE
00091 
00092   /* Maximum nice priority allowed to raise to.
00093      Nice levels 19 .. -20 correspond to 0 .. 39
00094      values of this resource limit.  */
00095   __RLIMIT_NICE = 13,
00096 #define RLIMIT_NICE __RLIMIT_NICE
00097 
00098   /* Maximum realtime priority allowed for non-priviledged
00099      processes.  */
00100   __RLIMIT_RTPRIO = 14,
00101 #define RLIMIT_RTPRIO __RLIMIT_RTPRIO
00102 
00103   __RLIMIT_NLIMITS = 15,
00104   __RLIM_NLIMITS = __RLIMIT_NLIMITS
00105 #define RLIMIT_NLIMITS __RLIMIT_NLIMITS
00106 #define RLIM_NLIMITS __RLIM_NLIMITS
00107 };
00108 
00109 /* Value to indicate that there is no limit.  */
00110 #ifndef __USE_FILE_OFFSET64
00111 # define RLIM_INFINITY ((unsigned long int)(~0UL))
00112 #else
00113 # define RLIM_INFINITY 0xffffffffffffffffuLL
00114 #endif
00115 
00116 #ifdef __USE_LARGEFILE64
00117 # define RLIM64_INFINITY 0xffffffffffffffffuLL
00118 #endif
00119 
00120 /* We can represent all limits.  */
00121 #define RLIM_SAVED_MAX      RLIM_INFINITY
00122 #define RLIM_SAVED_CUR      RLIM_INFINITY
00123 
00124 
00125 /* Type for resource quantity measurement.  */
00126 #ifndef __USE_FILE_OFFSET64
00127 typedef __rlim_t rlim_t;
00128 #else
00129 typedef __rlim64_t rlim_t;
00130 #endif
00131 #ifdef __USE_LARGEFILE64
00132 typedef __rlim64_t rlim64_t;
00133 #endif
00134 
00135 struct rlimit
00136   {
00137     /* The current (soft) limit.  */
00138     rlim_t rlim_cur;
00139     /* The hard limit.  */
00140     rlim_t rlim_max;
00141   };
00142 
00143 #ifdef __USE_LARGEFILE64
00144 struct rlimit64
00145   {
00146     /* The current (soft) limit.  */
00147     rlim64_t rlim_cur;
00148     /* The hard limit.  */
00149     rlim64_t rlim_max;
00150  };
00151 #endif
00152 
00153 /* Whose usage statistics do you want?  */
00154 enum __rusage_who
00155 {
00156   /* The calling process.  */
00157   RUSAGE_SELF = 0,
00158 #define RUSAGE_SELF RUSAGE_SELF
00159 
00160   /* All of its terminated child processes.  */
00161   RUSAGE_CHILDREN = -1,
00162 #define RUSAGE_CHILDREN RUSAGE_CHILDREN
00163 
00164 #ifdef __USE_GNU
00165   /* The calling thread.  */
00166   RUSAGE_THREAD = 1
00167 # define RUSAGE_THREAD RUSAGE_THREAD
00168   /* Name for the same functionality on Solaris.  */
00169 # define RUSAGE_LWP RUSAGE_THREAD
00170 #endif
00171 };
00172 
00173 #define __need_timeval
00174 #include <bits/time.h>             /* For `struct timeval'.  */
00175 
00176 /* Structure which says how much of each resource has been used.  */
00177 struct rusage
00178   {
00179     /* Total amount of user time used.  */
00180     struct timeval ru_utime;
00181     /* Total amount of system time used.  */
00182     struct timeval ru_stime;
00183     /* Maximum resident set size (in kilobytes).  */
00184     long int ru_maxrss;
00185     /* Amount of sharing of text segment memory
00186        with other processes (kilobyte-seconds).  */
00187     long int ru_ixrss;
00188     /* Amount of data segment memory used (kilobyte-seconds).  */
00189     long int ru_idrss;
00190     /* Amount of stack memory used (kilobyte-seconds).  */
00191     long int ru_isrss;
00192     /* Number of soft page faults (i.e. those serviced by reclaiming
00193        a page from the list of pages awaiting reallocation.  */
00194     long int ru_minflt;
00195     /* Number of hard page faults (i.e. those that required I/O).  */
00196     long int ru_majflt;
00197     /* Number of times a process was swapped out of physical memory.  */
00198     long int ru_nswap;
00199     /* Number of input operations via the file system.  Note: This
00200        and `ru_oublock' do not include operations with the cache.  */
00201     long int ru_inblock;
00202     /* Number of output operations via the file system.  */
00203     long int ru_oublock;
00204     /* Number of IPC messages sent.  */
00205     long int ru_msgsnd;
00206     /* Number of IPC messages received.  */
00207     long int ru_msgrcv;
00208     /* Number of signals delivered.  */
00209     long int ru_nsignals;
00210     /* Number of voluntary context switches, i.e. because the process
00211        gave up the process before it had to (usually to wait for some
00212        resource to be available).  */
00213     long int ru_nvcsw;
00214     /* Number of involuntary context switches, i.e. a higher priority process
00215        became runnable or the current process used up its time slice.  */
00216     long int ru_nivcsw;
00217   };
00218 
00219 /* Priority limits.  */
00220 #define PRIO_MIN     -20    /* Minimum priority a process can have.  */
00221 #define PRIO_MAX     20     /* Maximum priority a process can have.  */
00222 
00223 /* The type of the WHICH argument to `getpriority' and `setpriority',
00224    indicating what flavor of entity the WHO argument specifies.  */
00225 enum __priority_which
00226 {
00227   PRIO_PROCESS = 0,         /* WHO is a process ID.  */
00228 #define PRIO_PROCESS PRIO_PROCESS
00229   PRIO_PGRP = 1,            /* WHO is a process group ID.  */
00230 #define PRIO_PGRP PRIO_PGRP
00231   PRIO_USER = 2                    /* WHO is a user ID.  */
00232 #define PRIO_USER PRIO_USER
00233 };