resource.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1982, 1986, 1993
00003  *      The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 4. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  *      @(#)resource.h  8.4 (Berkeley) 1/9/95
00030  * $FreeBSD: src/sys/sys/resource.h,v 1.29 2005/01/07 02:29:23 imp Exp $
00031  *
00032  * © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
00033  */
00034 
00035 #ifndef _SYS_RESOURCE_H_
00036 #define _SYS_RESOURCE_H_
00037 
00038 #include <sys/cdefs.h>
00039 #include <sys/_timeval.h>
00040 #include <sys/_types.h>
00041 
00042 #ifdef __SYMBIAN32__
00043 #include <_ansi.h>
00044 //__SYMBIAN32__
00045 #endif
00046 /*
00047  * Process priority specifications to get/setpriority.
00048  */
00049 #define PRIO_MIN        -20
00050 #define PRIO_MAX        20
00051 
00052 #define PRIO_PROCESS    0
00053 #define PRIO_PGRP       1
00054 #define PRIO_USER       2
00055 
00056 #ifdef __SYMBIAN32__
00057 enum {
00058     UPPER_LIMIT_PRIORITY_HIGHEST = -20,
00059     LOWER_LIMIT_PRIORITY_HIGHEST = -16,
00060 
00061     UPPER_LIMIT_PRIORITY_ABOVE_NORMAL = -15,
00062     LOWER_LIMIT_PRIORITY_ABOVE_NORMAL = -6,
00063 
00064     UPPER_LIMIT_PRIORITY_NORMAL = -5,
00065     LOWER_LIMIT_PRIORITY_NORMAL = 4,
00066 
00067     UPPER_LIMIT_PRIORITY_BELOW_NORMAL = 5,
00068     LOWER_LIMIT_PRIORITY_BELOW_NORMAL = 14,
00069 
00070     UPPER_LIMIT_PRIORITY_LOWEST = 15,
00071     LOWER_LIMIT_PRIORITY_LOWEST = 20
00072 };
00073 #endif /* __SYMBIAN32__ */
00074 /*
00075  * Resource utilization information.
00076  *
00077  * Locking key:
00078  *      c - locked by proc mtx
00079  *      j - locked by sched_lock mtx
00080  *      n - not locked, lazy
00081  */
00082 
00083 #define RUSAGE_SELF     0
00084 #define RUSAGE_CHILDREN -1
00085 
00086 struct rusage {
00087         struct timeval ru_utime;        /* (n) user time used */
00088         struct timeval ru_stime;        /* (n) system time used */
00089         long    ru_maxrss;              /* (j) max resident set size */
00090 #define ru_first        ru_ixrss
00091         long    ru_ixrss;               /* (j) integral shared memory size */
00092         long    ru_idrss;               /* (j) integral unshared data " */
00093         long    ru_isrss;               /* (j) integral unshared stack " */
00094         long    ru_minflt;              /* (c) page reclaims */
00095         long    ru_majflt;              /* (c) page faults */
00096         long    ru_nswap;               /* (c + j) swaps */
00097         long    ru_inblock;             /* (n) block input operations */
00098         long    ru_oublock;             /* (n) block output operations */
00099         long    ru_msgsnd;              /* (n) messages sent */
00100         long    ru_msgrcv;              /* (n) messages received */
00101         long    ru_nsignals;            /* (c) signals received */
00102         long    ru_nvcsw;               /* (j) voluntary context switches */
00103         long    ru_nivcsw;              /* (j) involuntary " */
00104 #define ru_last         ru_nivcsw
00105 };
00106 
00107 /*
00108  * Resource limits
00109  */
00110 #define RLIMIT_CPU      0               /* cpu time in milliseconds */
00111 #define RLIMIT_FSIZE    1               /* maximum file size */
00112 #define RLIMIT_DATA     2               /* data size */
00113 #define RLIMIT_STACK    3               /* stack size */
00114 #define RLIMIT_CORE     4               /* core file size */
00115 #define RLIMIT_RSS      5               /* resident set size */
00116 #define RLIMIT_MEMLOCK  6               /* locked-in-memory address space */
00117 #define RLIMIT_NPROC    7               /* number of processes */
00118 #define RLIMIT_NOFILE   8               /* number of open files */
00119 #define RLIMIT_SBSIZE   9               /* maximum size of all socket buffers */
00120 #define RLIMIT_VMEM     10              /* virtual process size (inclusive of mmap) */
00121 #define RLIMIT_AS       RLIMIT_VMEM     /* standard name for RLIMIT_VMEM */
00122 
00123 #define RLIM_NLIMITS    11              /* number of resource limits */
00124 
00125 #define RLIM_INFINITY   ((rlim_t)(((uint64_t)1 << 63) - 1))
00126 /* XXX Missing: RLIM_SAVED_MAX, RLIM_SAVED_CUR */
00127 
00128 
00129 /*
00130  * Resource limit string identifiers
00131  */
00132 
00133 #ifdef _RLIMIT_IDENT
00134 static char *rlimit_ident[] = {
00135         "cpu",
00136         "fsize",
00137         "data",
00138         "stack",
00139         "core",
00140         "rss",
00141         "memlock",
00142         "nproc",
00143         "nofile",
00144         "sbsize",
00145         "vmem",
00146 };
00147 #endif
00148 
00149 #ifndef _RLIM_T_DECLARED
00150 typedef __rlim_t        rlim_t;
00151 #define _RLIM_T_DECLARED
00152 #endif
00153 
00154 struct rlimit {
00155         rlim_t  rlim_cur;               /* current (soft) limit */
00156         rlim_t  rlim_max;               /* maximum value for rlim_cur */
00157 };
00158 
00159 #if __BSD_VISIBLE
00160 
00161 struct orlimit {
00162         __int32_t       rlim_cur;       /* current (soft) limit */
00163         __int32_t       rlim_max;       /* maximum value for rlim_cur */
00164 };
00165 
00166 struct loadavg {
00167         __fixpt_t       ldavg[3];
00168         long            fscale;
00169 };
00170 
00171 #define CP_USER         0
00172 #define CP_NICE         1
00173 #define CP_SYS          2
00174 #define CP_INTR         3
00175 #define CP_IDLE         4
00176 #define CPUSTATES       5
00177 
00178 #endif  /* __BSD_VISIBLE */
00179 
00180 #ifdef _KERNEL
00181 
00182 extern struct loadavg averunnable;
00183 extern long cp_time[CPUSTATES];
00184 
00185 #else
00186 
00187 __BEGIN_DECLS
00188 /* XXX 2nd arg to [gs]etpriority() should be an id_t */
00189 IMPORT_C int    getpriority(int, int);
00190 IMPORT_C int    setpriority(int, int, int);
00191 __END_DECLS
00192 
00193 #endif  /* _KERNEL */
00194 #endif  /* !_SYS_RESOURCE_H_ */

Copyright © Nokia Corporation 2001-2008
Back to top