Back to index

glibc  2.9
resource.h
Go to the documentation of this file.
00001 /* Bit values & structures for resource limits.  Linux/MIPS version.
00002    Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2004, 2005, 2006
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 = 7,
00060 #define       RLIMIT_RSS __RLIMIT_RSS
00061 
00062   /* Number of open files.  */
00063   RLIMIT_NOFILE = 5,
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 = 6,
00070 #define RLIMIT_AS RLIMIT_AS
00071 
00072   /* Number of processes.  */
00073   __RLIMIT_NPROC = 8,
00074 #define RLIMIT_NPROC __RLIMIT_NPROC
00075 
00076   /* Locked-in-memory address space.  */
00077   __RLIMIT_MEMLOCK = 9,
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 #if _MIPS_SIM == _ABI64
00111 /* The N64 syscall uses this value.  */
00112 # define RLIM_INFINITY 0xffffffffffffffffUL
00113 # ifdef __USE_LARGEFILE64
00114 #  define RLIM64_INFINITY 0xffffffffffffffffUL
00115 # endif
00116 #else
00117 /* The O32 and N32 syscalls use 0x7fffffff.  */
00118 # ifndef __USE_FILE_OFFSET64
00119 #  define RLIM_INFINITY ((long int)(~0UL >> 1))
00120 # else
00121 #  define RLIM_INFINITY 0x7fffffffffffffffULL
00122 # endif
00123 # ifdef __USE_LARGEFILE64
00124 #  define RLIM64_INFINITY 0x7fffffffffffffffULL
00125 # endif
00126 #endif
00127 
00128 /* We can represent all limits.  */
00129 #define RLIM_SAVED_MAX      RLIM_INFINITY
00130 #define RLIM_SAVED_CUR      RLIM_INFINITY
00131 
00132 
00133 /* Type for resource quantity measurement.  */
00134 #ifndef __USE_FILE_OFFSET64
00135 typedef __rlim_t rlim_t;
00136 #else
00137 typedef __rlim64_t rlim_t;
00138 #endif
00139 #ifdef __USE_LARGEFILE64
00140 typedef __rlim64_t rlim64_t;
00141 #endif
00142 
00143 struct rlimit
00144   {
00145     /* The current (soft) limit.  */
00146     rlim_t rlim_cur;
00147     /* The hard limit.  */
00148     rlim_t rlim_max;
00149   };
00150 
00151 #ifdef __USE_LARGEFILE64
00152 struct rlimit64
00153   {
00154     /* The current (soft) limit.  */
00155     rlim64_t rlim_cur;
00156     /* The hard limit.  */
00157     rlim64_t rlim_max;
00158  };
00159 #endif
00160 
00161 /* Whose usage statistics do you want?  */
00162 enum __rusage_who
00163 {
00164   /* The calling process.  */
00165   RUSAGE_SELF = 0,
00166 #define RUSAGE_SELF RUSAGE_SELF
00167 
00168   /* All of its terminated child processes.  */
00169   RUSAGE_CHILDREN = -1,
00170 #define RUSAGE_CHILDREN RUSAGE_CHILDREN
00171 
00172 #ifdef __USE_GNU
00173   /* The calling thread.  */
00174   RUSAGE_THREAD = 1
00175 # define RUSAGE_THREAD RUSAGE_THREAD
00176   /* Name for the same functionality on Solaris.  */
00177 # define RUSAGE_LWP RUSAGE_THREAD
00178 #endif
00179 };
00180 
00181 #define __need_timeval
00182 #include <bits/time.h>             /* For `struct timeval'.  */
00183 
00184 /* Structure which says how much of each resource has been used.  */
00185 struct rusage
00186   {
00187     /* Total amount of user time used.  */
00188     struct timeval ru_utime;
00189     /* Total amount of system time used.  */
00190     struct timeval ru_stime;
00191     /* Maximum resident set size (in kilobytes).  */
00192     long int ru_maxrss;
00193     /* Amount of sharing of text segment memory
00194        with other processes (kilobyte-seconds).  */
00195     long int ru_ixrss;
00196     /* Amount of data segment memory used (kilobyte-seconds).  */
00197     long int ru_idrss;
00198     /* Amount of stack memory used (kilobyte-seconds).  */
00199     long int ru_isrss;
00200     /* Number of soft page faults (i.e. those serviced by reclaiming
00201        a page from the list of pages awaiting reallocation.  */
00202     long int ru_minflt;
00203     /* Number of hard page faults (i.e. those that required I/O).  */
00204     long int ru_majflt;
00205     /* Number of times a process was swapped out of physical memory.  */
00206     long int ru_nswap;
00207     /* Number of input operations via the file system.  Note: This
00208        and `ru_oublock' do not include operations with the cache.  */
00209     long int ru_inblock;
00210     /* Number of output operations via the file system.  */
00211     long int ru_oublock;
00212     /* Number of IPC messages sent.  */
00213     long int ru_msgsnd;
00214     /* Number of IPC messages received.  */
00215     long int ru_msgrcv;
00216     /* Number of signals delivered.  */
00217     long int ru_nsignals;
00218     /* Number of voluntary context switches, i.e. because the process
00219        gave up the process before it had to (usually to wait for some
00220        resource to be available).  */
00221     long int ru_nvcsw;
00222     /* Number of involuntary context switches, i.e. a higher priority process
00223        became runnable or the current process used up its time slice.  */
00224     long int ru_nivcsw;
00225   };
00226 
00227 /* Priority limits.  */
00228 #define PRIO_MIN     -20    /* Minimum priority a process can have.  */
00229 #define PRIO_MAX     20     /* Maximum priority a process can have.  */
00230 
00231 /* The type of the WHICH argument to `getpriority' and `setpriority',
00232    indicating what flavor of entity the WHO argument specifies.  */
00233 enum __priority_which
00234 {
00235   PRIO_PROCESS = 0,         /* WHO is a process ID.  */
00236 #define PRIO_PROCESS PRIO_PROCESS
00237   PRIO_PGRP = 1,            /* WHO is a process group ID.  */
00238 #define PRIO_PGRP PRIO_PGRP
00239   PRIO_USER = 2                    /* WHO is a user ID.  */
00240 #define PRIO_USER PRIO_USER
00241 };