williamr@2
|
1 |
/*-
|
williamr@2
|
2 |
* Copyright (c) 1982, 1986, 1993
|
williamr@2
|
3 |
* The Regents of the University of California. All rights reserved.
|
williamr@2
|
4 |
*
|
williamr@2
|
5 |
* Redistribution and use in source and binary forms, with or without
|
williamr@2
|
6 |
* modification, are permitted provided that the following conditions
|
williamr@2
|
7 |
* are met:
|
williamr@2
|
8 |
* 1. Redistributions of source code must retain the above copyright
|
williamr@2
|
9 |
* notice, this list of conditions and the following disclaimer.
|
williamr@2
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright
|
williamr@2
|
11 |
* notice, this list of conditions and the following disclaimer in the
|
williamr@2
|
12 |
* documentation and/or other materials provided with the distribution.
|
williamr@2
|
13 |
* 4. Neither the name of the University nor the names of its contributors
|
williamr@2
|
14 |
* may be used to endorse or promote products derived from this software
|
williamr@2
|
15 |
* without specific prior written permission.
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
williamr@2
|
18 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
williamr@2
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
williamr@2
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
williamr@2
|
21 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
williamr@2
|
22 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
williamr@2
|
23 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
williamr@2
|
24 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
williamr@2
|
25 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
williamr@2
|
26 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
williamr@2
|
27 |
* SUCH DAMAGE.
|
williamr@2
|
28 |
*
|
williamr@2
|
29 |
* @(#)resource.h 8.4 (Berkeley) 1/9/95
|
williamr@2
|
30 |
* $FreeBSD: src/sys/sys/resource.h,v 1.29 2005/01/07 02:29:23 imp Exp $
|
williamr@2
|
31 |
*
|
williamr@2
|
32 |
* © Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
|
williamr@2
|
33 |
*/
|
williamr@2
|
34 |
|
williamr@2
|
35 |
#ifndef _SYS_RESOURCE_H_
|
williamr@2
|
36 |
#define _SYS_RESOURCE_H_
|
williamr@2
|
37 |
|
williamr@2
|
38 |
#include <sys/cdefs.h>
|
williamr@2
|
39 |
#include <sys/_timeval.h>
|
williamr@2
|
40 |
#include <sys/_types.h>
|
williamr@2
|
41 |
|
williamr@2
|
42 |
#ifdef __SYMBIAN32__
|
williamr@2
|
43 |
#include <_ansi.h>
|
williamr@2
|
44 |
#endif //__SYMBIAN32__
|
williamr@2
|
45 |
/*
|
williamr@2
|
46 |
* Process priority specifications to get/setpriority.
|
williamr@2
|
47 |
*/
|
williamr@2
|
48 |
#define PRIO_MIN -20
|
williamr@2
|
49 |
#define PRIO_MAX 20
|
williamr@2
|
50 |
|
williamr@2
|
51 |
#define PRIO_PROCESS 0
|
williamr@2
|
52 |
#define PRIO_PGRP 1
|
williamr@2
|
53 |
#define PRIO_USER 2
|
williamr@2
|
54 |
|
williamr@2
|
55 |
#ifdef __SYMBIAN32__
|
williamr@2
|
56 |
enum {
|
williamr@2
|
57 |
UPPER_LIMIT_PRIORITY_HIGHEST = -20,
|
williamr@2
|
58 |
LOWER_LIMIT_PRIORITY_HIGHEST = -16,
|
williamr@2
|
59 |
|
williamr@2
|
60 |
UPPER_LIMIT_PRIORITY_ABOVE_NORMAL = -15,
|
williamr@2
|
61 |
LOWER_LIMIT_PRIORITY_ABOVE_NORMAL = -6,
|
williamr@2
|
62 |
|
williamr@2
|
63 |
UPPER_LIMIT_PRIORITY_NORMAL = -5,
|
williamr@2
|
64 |
LOWER_LIMIT_PRIORITY_NORMAL = 4,
|
williamr@2
|
65 |
|
williamr@2
|
66 |
UPPER_LIMIT_PRIORITY_BELOW_NORMAL = 5,
|
williamr@2
|
67 |
LOWER_LIMIT_PRIORITY_BELOW_NORMAL = 14,
|
williamr@2
|
68 |
|
williamr@2
|
69 |
UPPER_LIMIT_PRIORITY_LOWEST = 15,
|
williamr@2
|
70 |
LOWER_LIMIT_PRIORITY_LOWEST = 20
|
williamr@2
|
71 |
};
|
williamr@2
|
72 |
#endif /* __SYMBIAN32__ */
|
williamr@2
|
73 |
/*
|
williamr@2
|
74 |
* Resource utilization information.
|
williamr@2
|
75 |
*
|
williamr@2
|
76 |
* Locking key:
|
williamr@2
|
77 |
* c - locked by proc mtx
|
williamr@2
|
78 |
* j - locked by sched_lock mtx
|
williamr@2
|
79 |
* n - not locked, lazy
|
williamr@2
|
80 |
*/
|
williamr@2
|
81 |
|
williamr@2
|
82 |
#define RUSAGE_SELF 0
|
williamr@2
|
83 |
#define RUSAGE_CHILDREN -1
|
williamr@2
|
84 |
|
williamr@2
|
85 |
struct rusage {
|
williamr@2
|
86 |
struct timeval ru_utime; /* (n) user time used */
|
williamr@2
|
87 |
struct timeval ru_stime; /* (n) system time used */
|
williamr@2
|
88 |
long ru_maxrss; /* (j) max resident set size */
|
williamr@2
|
89 |
#define ru_first ru_ixrss
|
williamr@2
|
90 |
long ru_ixrss; /* (j) integral shared memory size */
|
williamr@2
|
91 |
long ru_idrss; /* (j) integral unshared data " */
|
williamr@2
|
92 |
long ru_isrss; /* (j) integral unshared stack " */
|
williamr@2
|
93 |
long ru_minflt; /* (c) page reclaims */
|
williamr@2
|
94 |
long ru_majflt; /* (c) page faults */
|
williamr@2
|
95 |
long ru_nswap; /* (c + j) swaps */
|
williamr@2
|
96 |
long ru_inblock; /* (n) block input operations */
|
williamr@2
|
97 |
long ru_oublock; /* (n) block output operations */
|
williamr@2
|
98 |
long ru_msgsnd; /* (n) messages sent */
|
williamr@2
|
99 |
long ru_msgrcv; /* (n) messages received */
|
williamr@2
|
100 |
long ru_nsignals; /* (c) signals received */
|
williamr@2
|
101 |
long ru_nvcsw; /* (j) voluntary context switches */
|
williamr@2
|
102 |
long ru_nivcsw; /* (j) involuntary " */
|
williamr@2
|
103 |
#define ru_last ru_nivcsw
|
williamr@2
|
104 |
};
|
williamr@2
|
105 |
|
williamr@2
|
106 |
/*
|
williamr@2
|
107 |
* Resource limits
|
williamr@2
|
108 |
*/
|
williamr@2
|
109 |
#define RLIMIT_CPU 0 /* cpu time in milliseconds */
|
williamr@2
|
110 |
#define RLIMIT_FSIZE 1 /* maximum file size */
|
williamr@2
|
111 |
#define RLIMIT_DATA 2 /* data size */
|
williamr@2
|
112 |
#define RLIMIT_STACK 3 /* stack size */
|
williamr@2
|
113 |
#define RLIMIT_CORE 4 /* core file size */
|
williamr@2
|
114 |
#define RLIMIT_RSS 5 /* resident set size */
|
williamr@2
|
115 |
#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */
|
williamr@2
|
116 |
#define RLIMIT_NPROC 7 /* number of processes */
|
williamr@2
|
117 |
#define RLIMIT_NOFILE 8 /* number of open files */
|
williamr@2
|
118 |
#define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */
|
williamr@2
|
119 |
#define RLIMIT_VMEM 10 /* virtual process size (inclusive of mmap) */
|
williamr@2
|
120 |
#define RLIMIT_AS RLIMIT_VMEM /* standard name for RLIMIT_VMEM */
|
williamr@2
|
121 |
|
williamr@2
|
122 |
#define RLIM_NLIMITS 11 /* number of resource limits */
|
williamr@2
|
123 |
|
williamr@2
|
124 |
#define RLIM_INFINITY ((rlim_t)(((uint64_t)1 << 63) - 1))
|
williamr@2
|
125 |
/* XXX Missing: RLIM_SAVED_MAX, RLIM_SAVED_CUR */
|
williamr@2
|
126 |
|
williamr@2
|
127 |
|
williamr@2
|
128 |
/*
|
williamr@2
|
129 |
* Resource limit string identifiers
|
williamr@2
|
130 |
*/
|
williamr@2
|
131 |
|
williamr@2
|
132 |
#ifdef _RLIMIT_IDENT
|
williamr@2
|
133 |
static char *rlimit_ident[] = {
|
williamr@2
|
134 |
"cpu",
|
williamr@2
|
135 |
"fsize",
|
williamr@2
|
136 |
"data",
|
williamr@2
|
137 |
"stack",
|
williamr@2
|
138 |
"core",
|
williamr@2
|
139 |
"rss",
|
williamr@2
|
140 |
"memlock",
|
williamr@2
|
141 |
"nproc",
|
williamr@2
|
142 |
"nofile",
|
williamr@2
|
143 |
"sbsize",
|
williamr@2
|
144 |
"vmem",
|
williamr@2
|
145 |
};
|
williamr@2
|
146 |
#endif
|
williamr@2
|
147 |
|
williamr@2
|
148 |
#ifndef _RLIM_T_DECLARED
|
williamr@2
|
149 |
typedef __rlim_t rlim_t;
|
williamr@2
|
150 |
#define _RLIM_T_DECLARED
|
williamr@2
|
151 |
#endif
|
williamr@2
|
152 |
|
williamr@2
|
153 |
struct rlimit {
|
williamr@2
|
154 |
rlim_t rlim_cur; /* current (soft) limit */
|
williamr@2
|
155 |
rlim_t rlim_max; /* maximum value for rlim_cur */
|
williamr@2
|
156 |
};
|
williamr@2
|
157 |
|
williamr@2
|
158 |
#if __BSD_VISIBLE
|
williamr@2
|
159 |
|
williamr@2
|
160 |
struct orlimit {
|
williamr@2
|
161 |
__int32_t rlim_cur; /* current (soft) limit */
|
williamr@2
|
162 |
__int32_t rlim_max; /* maximum value for rlim_cur */
|
williamr@2
|
163 |
};
|
williamr@2
|
164 |
|
williamr@2
|
165 |
struct loadavg {
|
williamr@2
|
166 |
__fixpt_t ldavg[3];
|
williamr@2
|
167 |
long fscale;
|
williamr@2
|
168 |
};
|
williamr@2
|
169 |
|
williamr@2
|
170 |
#define CP_USER 0
|
williamr@2
|
171 |
#define CP_NICE 1
|
williamr@2
|
172 |
#define CP_SYS 2
|
williamr@2
|
173 |
#define CP_INTR 3
|
williamr@2
|
174 |
#define CP_IDLE 4
|
williamr@2
|
175 |
#define CPUSTATES 5
|
williamr@2
|
176 |
|
williamr@2
|
177 |
#endif /* __BSD_VISIBLE */
|
williamr@2
|
178 |
|
williamr@2
|
179 |
#ifdef _KERNEL
|
williamr@2
|
180 |
|
williamr@2
|
181 |
extern struct loadavg averunnable;
|
williamr@2
|
182 |
extern long cp_time[CPUSTATES];
|
williamr@2
|
183 |
|
williamr@2
|
184 |
#else
|
williamr@2
|
185 |
|
williamr@2
|
186 |
__BEGIN_DECLS
|
williamr@2
|
187 |
/* XXX 2nd arg to [gs]etpriority() should be an id_t */
|
williamr@2
|
188 |
IMPORT_C int getpriority(int, int);
|
williamr@2
|
189 |
IMPORT_C int setpriority(int, int, int);
|
williamr@2
|
190 |
__END_DECLS
|
williamr@2
|
191 |
|
williamr@2
|
192 |
#endif /* _KERNEL */
|
williamr@2
|
193 |
#endif /* !_SYS_RESOURCE_H_ */
|