os161-1.99
 All Data Structures
resource.h
00001 /*
00002  * Copyright (c) 2004, 2008
00003  *      The President and Fellows of Harvard College.
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  * 3. 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 UNIVERSITY 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 UNIVERSITY 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 
00030 #ifndef _KERN_RESOURCE_H_
00031 #define _KERN_RESOURCE_H_
00032 
00033 /*
00034  * Definitions for resource usage and limits.
00035  *
00036  * Not very important.
00037  */
00038 
00039 
00040 /* priorities for setpriority() */
00041 #define PRIO_MIN        (-20)
00042 #define PRIO_MAX        20
00043 
00044 /* "which" codes for setpriority() */
00045 #define PRIO_PROCESS    0
00046 #define PRIO_PGRP       1
00047 #define PRIO_USER       2
00048 
00049 /* flags for getrusage() */
00050 #define RUSAGE_SELF     0
00051 #define RUSAGE_CHILDREN (-1)
00052 
00053 struct rusage {
00054         struct timeval ru_utime;
00055         struct timeval ru_stime;
00056         __size_t ru_maxrss;             /* maximum RSS during lifespan (kb) */
00057         __counter_t ru_ixrss;           /* text memory usage (kb-ticks) */
00058         __counter_t ru_idrss;           /* data memory usage (kb-ticks) */
00059         __counter_t ru_isrss;           /* stack memory usage (kb-ticks) */
00060         __counter_t ru_minflt;          /* minor VM faults (count) */
00061         __counter_t ru_majflt;          /* major VM faults (count) */
00062         __counter_t ru_nswap;           /* whole-process swaps (count) */
00063         __counter_t ru_inblock;         /* file blocks read (count) */
00064         __counter_t ru_oublock;         /* file blocks written (count) */
00065         __counter_t ru_msgrcv;          /* socket/pipe packets rcv'd (count) */
00066         __counter_t ru_msgsnd;          /* socket/pipe packets sent (count) */
00067         __counter_t ru_nsignals;        /* signals delivered (count) */
00068         __counter_t ru_nvcsw;           /* voluntary context switches (count)*/
00069         __counter_t ru_nivcsw;          /* involuntary ditto (count) */
00070 };
00071 
00072 /* limit codes for getrusage/setrusage */
00073 
00074 #define RLIMIT_NPROC            0       /* max procs per user (count) */
00075 #define RLIMIT_NOFILE           1       /* max open files per proc (count) */
00076 #define RLIMIT_CPU              2       /* cpu usage (seconds) */
00077 #define RLIMIT_DATA             3       /* max .data/sbrk size (bytes) */
00078 #define RLIMIT_STACK            4       /* max stack size (bytes) */
00079 #define RLIMIT_MEMLOCK          5       /* max locked memory region (bytes) */
00080 #define RLIMIT_RSS              6       /* max RSS (bytes) */
00081 #define RLIMIT_CORE             7       /* core file size (bytes) */
00082 #define RLIMIT_FSIZE            8       /* max file size (bytes) */
00083 #define __RLIMIT_NUM            9       /* number of limits */
00084 
00085 struct rlimit {
00086         __rlim_t rlim_cur;      /* soft limit */
00087         __rlim_t rlim_max;      /* hard limit */
00088 };
00089 
00090 #define RLIM_INFINITY   (~(__rlim_t)0)
00091 
00092 #endif /* _KERN_RESOURCE_H_ */
 All Data Structures