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