Back to index

glibc  2.9
resource.h
Go to the documentation of this file.
00001 /* Bit values & structures for resource limits.  4.4 BSD/generic GNU version.
00002    Copyright (C) 1994,1996,1997,1998,2006 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 /* These are the values for 4.4 BSD and GNU.  Earlier BSD systems have a
00027    subset of these kinds of resource limit.  In systems where `getrlimit'
00028    and `setrlimit' are not system calls, these are the values used by the C
00029    library to emulate them.  */
00030 
00031 /* Kinds of resource limit.  */
00032 enum __rlimit_resource
00033   {
00034     /* Per-process CPU limit, in seconds.  */
00035     RLIMIT_CPU,
00036 #define       RLIMIT_CPU    RLIMIT_CPU
00037     /* Largest file that can be created, in bytes.  */
00038     RLIMIT_FSIZE,
00039 #define       RLIMIT_FSIZE  RLIMIT_FSIZE
00040     /* Maximum size of data segment, in bytes.  */
00041     RLIMIT_DATA,
00042 #define       RLIMIT_DATA   RLIMIT_DATA
00043     /* Maximum size of stack segment, in bytes.  */
00044     RLIMIT_STACK,
00045 #define       RLIMIT_STACK  RLIMIT_STACK
00046     /* Largest core file that can be created, in bytes.  */
00047     RLIMIT_CORE,
00048 #define       RLIMIT_CORE   RLIMIT_CORE
00049     /* Largest resident set size, in bytes.
00050        This affects swapping; processes that are exceeding their
00051        resident set size will be more likely to have physical memory
00052        taken from them.  */
00053     RLIMIT_RSS,
00054 #define       RLIMIT_RSS    RLIMIT_RSS
00055     /* Locked-in-memory address space.  */
00056     RLIMIT_MEMLOCK,
00057 #define       RLIMIT_MEMLOCK       RLIMIT_MEMLOCK
00058     /* Number of processes.  */
00059     RLIMIT_NPROC,
00060 #define       RLIMIT_NPROC  RLIMIT_NPROC
00061     /* Number of open files.  */
00062     RLIMIT_OFILE,
00063     RLIMIT_NOFILE = RLIMIT_OFILE, /* Another name for the same thing.  */
00064 #define       RLIMIT_OFILE  RLIMIT_OFILE
00065 #define       RLIMIT_NOFILE RLIMIT_NOFILE
00066     /* Maximum size of all socket buffers.  */
00067     RLIMIT_SBSIZE,
00068 #define RLIMIT_SBSIZE       RLIMIT_SBSIZE
00069     /* Maximum size in bytes of the process address space.  */
00070     RLIMIT_AS,
00071     RLIMIT_VMEM = RLIMIT_AS,       /* Another name for the same thing.  */
00072 #define RLIMIT_AS    RLIMIT_AS
00073 #define RLIMIT_VMEM  RLIMIT_AS
00074 
00075     RLIMIT_NLIMITS,         /* Number of limit flavors.  */
00076     RLIM_NLIMITS = RLIMIT_NLIMITS /* Traditional name for same.  */
00077   };
00078 
00079 /* Value to indicate that there is no limit.  */
00080 #ifndef __USE_FILE_OFFSET64
00081 # define RLIM_INFINITY 0x7fffffff
00082 #else
00083 # define RLIM_INFINITY 0x7fffffffffffffffLL
00084 #endif
00085 
00086 #ifdef __USE_LARGEFILE64
00087 # define RLIM64_INFINITY 0x7fffffffffffffffLL
00088 #endif
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 /* The macro definitions are necessary because some programs want
00122    to test for operating system features with #ifdef RUSAGE_SELF.
00123    In ISO C the reflexive definition is a no-op.  */
00124   {
00125     /* The calling process.  */
00126     RUSAGE_SELF = 0,
00127 #define RUSAGE_SELF     RUSAGE_SELF
00128     /* All of its terminated child processes.  */
00129     RUSAGE_CHILDREN = -1
00130 #define RUSAGE_CHILDREN RUSAGE_CHILDREN
00131   };
00132 
00133 #define __need_timeval
00134 #include <bits/time.h>           /* For `struct timeval'.  */
00135 
00136 /* Structure which says how much of each resource has been used.  */
00137 struct rusage
00138   {
00139     /* Total amount of user time used.  */
00140     struct timeval ru_utime;
00141     /* Total amount of system time used.  */
00142     struct timeval ru_stime;
00143     /* Maximum resident set size (in kilobytes).  */
00144     long int ru_maxrss;
00145     /* Amount of sharing of text segment memory
00146        with other processes (kilobyte-seconds).  */
00147     long int ru_ixrss;
00148     /* Amount of data segment memory used (kilobyte-seconds).  */
00149     long int ru_idrss;
00150     /* Amount of stack memory used (kilobyte-seconds).  */
00151     long int ru_isrss;
00152     /* Number of soft page faults (i.e. those serviced by reclaiming
00153        a page from the list of pages awaiting reallocation.  */
00154     long int ru_minflt;
00155     /* Number of hard page faults (i.e. those that required I/O).  */
00156     long int ru_majflt;
00157     /* Number of times a process was swapped out of physical memory.  */
00158     long int ru_nswap;
00159     /* Number of input operations via the file system.  Note: This
00160        and `ru_oublock' do not include operations with the cache.  */
00161     long int ru_inblock;
00162     /* Number of output operations via the file system.  */
00163     long int ru_oublock;
00164     /* Number of IPC messages sent.  */
00165     long int ru_msgsnd;
00166     /* Number of IPC messages received.  */
00167     long int ru_msgrcv;
00168     /* Number of signals delivered.  */
00169     long int ru_nsignals;
00170     /* Number of voluntary context switches, i.e. because the process
00171        gave up the process before it had to (usually to wait for some
00172        resource to be available).  */
00173     long int ru_nvcsw;
00174     /* Number of involuntary context switches, i.e. a higher priority process
00175        became runnable or the current process used up its time slice.  */
00176     long int ru_nivcsw;
00177   };
00178 
00179 /* Priority limits.  */
00180 #define PRIO_MIN        -20     /* Minimum priority a process can have.  */
00181 #define PRIO_MAX        20      /* Maximum priority a process can have.  */
00182 
00183 /* The type of the WHICH argument to `getpriority' and `setpriority',
00184    indicating what flavor of entity the WHO argument specifies.  */
00185 enum __priority_which
00186   {
00187     PRIO_PROCESS = 0,           /* WHO is a process ID.  */
00188     PRIO_PGRP = 1,              /* WHO is a process group ID.  */
00189     PRIO_USER = 2               /* WHO is a user ID.  */
00190   };