Back to index

glibc  2.9
resource.h
Go to the documentation of this file.
00001 /* Bit values for resource limits.  SunOS 4 version.
00002    Copyright (C) 1994, 1996, 1997 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 /* These are the values for 4.4 BSD and GNU.  Earlier BSD systems have a
00025    subset of these kinds of resource limit.  In systems where `getrlimit'
00026    and `setrlimit' are not system calls, these are the values used by the C
00027    library to emulate them.  */
00028 
00029 #include <bits/types.h>
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     /* Number of open files.  */
00056     RLIMIT_NOFILE,
00057     RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same.  */
00058 #define       RLIMIT_NOFILE RLIMIT_NOFILE
00059 #define       RLIMIT_OFILE  RLIMIT_OFILE
00060 
00061     RLIM_NLIMITS
00062   };
00063 
00064 /* Value to indicate that there is no limit.  */
00065 #ifndef __USE_FILE_OFFSET64
00066 # define RLIM_INFINITY 0x7fffffff
00067 #else
00068 # define RLIM_INFINITY 0x7fffffffffffffffLL
00069 #endif
00070 
00071 #ifdef __USE_LARGEFILE64
00072 # define RLIM64_INFINITY 0x7fffffffffffffffLL
00073 #endif
00074 
00075 
00076 /* Type to represent quantities in resource limits.  */
00077 #ifndef __USE_FILE_OFFSET64
00078 typedef __rlim_t rlim_t;
00079 #else
00080 typedef __rlim64_t rlim_t;
00081 #endif
00082 
00083 struct rlimit
00084   {
00085     /* The current (soft) limit.  */
00086     rlim_t rlim_cur;
00087     /* The hard limit.  */
00088     rlim_t rlim_max;
00089   };
00090 
00091 #ifdef __USE_LARGEFILE64
00092 typedef __rlim64_t rlim64_t;
00093 
00094 struct rlimit64
00095   {
00096     /* The current (soft) limit.  */
00097     rlim64_t rlim_cur;
00098     /* The hard limit.  */
00099     rlim64_t rlim_max;
00100   };
00101 #endif
00102 
00103 /* Whose usage statistics do you want?  */
00104 enum __rusage_who
00105 /* The macro definitions are necessary because some programs want
00106    to test for operating system features with #ifdef RUSAGE_SELF.
00107    In ISO C the reflexive definition is a no-op.  */
00108   {
00109     /* The calling process.  */
00110     RUSAGE_SELF = 0,
00111 #define RUSAGE_SELF     RUSAGE_SELF
00112     /* All of its terminated child processes.  */
00113     RUSAGE_CHILDREN = -1
00114 #define RUSAGE_CHILDREN RUSAGE_CHILDREN
00115   };
00116 
00117 #define __need_timeval
00118 #include <bits/time.h>           /* For `struct timeval'.  */
00119 
00120 /* Structure which says how much of each resource has been used.  */
00121 struct rusage
00122   {
00123     /* Total amount of user time used.  */
00124     struct timeval ru_utime;
00125     /* Total amount of system time used.  */
00126     struct timeval ru_stime;
00127     /* Maximum resident set size (in kilobytes).  */
00128     long int ru_maxrss;
00129     /* Amount of sharing of text segment memory
00130        with other processes (kilobyte-seconds).  */
00131     long int ru_ixrss;
00132     /* Amount of data segment memory used (kilobyte-seconds).  */
00133     long int ru_idrss;
00134     /* Amount of stack memory used (kilobyte-seconds).  */
00135     long int ru_isrss;
00136     /* Number of soft page faults (i.e. those serviced by reclaiming
00137        a page from the list of pages awaiting reallocation.  */
00138     long int ru_minflt;
00139     /* Number of hard page faults (i.e. those that required I/O).  */
00140     long int ru_majflt;
00141     /* Number of times a process was swapped out of physical memory.  */
00142     long int ru_nswap;
00143     /* Number of input operations via the file system.  Note: This
00144        and `ru_oublock' do not include operations with the cache.  */
00145     long int ru_inblock;
00146     /* Number of output operations via the file system.  */
00147     long int ru_oublock;
00148     /* Number of IPC messages sent.  */
00149     long int ru_msgsnd;
00150     /* Number of IPC messages received.  */
00151     long int ru_msgrcv;
00152     /* Number of signals delivered.  */
00153     long int ru_nsignals;
00154     /* Number of voluntary context switches, i.e. because the process
00155        gave up the process before it had to (usually to wait for some
00156        resource to be available).  */
00157     long int ru_nvcsw;
00158     /* Number of involuntary context switches, i.e. a higher priority process
00159        became runnable or the current process used up its time slice.  */
00160     long int ru_nivcsw;
00161   };
00162 
00163 /* Priority limits.  */
00164 #define PRIO_MIN        -20     /* Minimum priority a process can have.  */
00165 #define PRIO_MAX        20      /* Maximum priority a process can have.  */
00166 
00167 /* The type of the WHICH argument to `getpriority' and `setpriority',
00168    indicating what flavor of entity the WHO argument specifies.  */
00169 enum __priority_which
00170   {
00171     PRIO_PROCESS = 0,           /* WHO is a process ID.  */
00172     PRIO_PGRP = 1,              /* WHO is a process group ID.  */
00173     PRIO_USER = 2               /* WHO is a user ID.  */
00174   };