/*1* Copyright (c) 2004, 20082* The President and Fellows of Harvard College.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the University nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _KERN_RESOURCE_H_30#define _KERN_RESOURCE_H_3132/*33* Definitions for resource usage and limits.34*35* Not very important.36*/373839/* priorities for setpriority() */40#define PRIO_MIN (-20)41#define PRIO_MAX 204243/* "which" codes for setpriority() */44#define PRIO_PROCESS 045#define PRIO_PGRP 146#define PRIO_USER 24748/* flags for getrusage() */49#define RUSAGE_SELF 050#define RUSAGE_CHILDREN (-1)5152struct rusage {53struct timeval ru_utime;54struct timeval ru_stime;55__size_t ru_maxrss; /* maximum RSS during lifespan (kb) */56__counter_t ru_ixrss; /* text memory usage (kb-ticks) */57__counter_t ru_idrss; /* data memory usage (kb-ticks) */58__counter_t ru_isrss; /* stack memory usage (kb-ticks) */59__counter_t ru_minflt; /* minor VM faults (count) */60__counter_t ru_majflt; /* major VM faults (count) */61__counter_t ru_nswap; /* whole-process swaps (count) */62__counter_t ru_inblock; /* file blocks read (count) */63__counter_t ru_oublock; /* file blocks written (count) */64__counter_t ru_msgrcv; /* socket/pipe packets rcv'd (count) */65__counter_t ru_msgsnd; /* socket/pipe packets sent (count) */66__counter_t ru_nsignals; /* signals delivered (count) */67__counter_t ru_nvcsw; /* voluntary context switches (count)*/68__counter_t ru_nivcsw; /* involuntary ditto (count) */69};7071/* limit codes for getrusage/setrusage */7273#define RLIMIT_NPROC 0 /* max procs per user (count) */74#define RLIMIT_NOFILE 1 /* max open files per proc (count) */75#define RLIMIT_CPU 2 /* cpu usage (seconds) */76#define RLIMIT_DATA 3 /* max .data/sbrk size (bytes) */77#define RLIMIT_STACK 4 /* max stack size (bytes) */78#define RLIMIT_MEMLOCK 5 /* max locked memory region (bytes) */79#define RLIMIT_RSS 6 /* max RSS (bytes) */80#define RLIMIT_CORE 7 /* core file size (bytes) */81#define RLIMIT_FSIZE 8 /* max file size (bytes) */82#define __RLIMIT_NUM 9 /* number of limits */8384struct rlimit {85__rlim_t rlim_cur; /* soft limit */86__rlim_t rlim_max; /* hard limit */87};8889#define RLIM_INFINITY (~(__rlim_t)0)9091#endif /* _KERN_RESOURCE_H_ */929394