Back to index

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