|
1 /** @file ../include/sys/resource.h |
|
2 @internalComponent |
|
3 */ |
|
4 |
|
5 /** @fn getpriority(int which, int who) |
|
6 @param which |
|
7 @param who |
|
8 |
|
9 Note: This description also covers the following functions - |
|
10 setpriority() |
|
11 |
|
12 @return Since getpriority can legitimately return the value -1, it is necessary |
|
13 to clear the external variable errno prior to the |
|
14 call, then check it afterward to determine |
|
15 if a -1 is an error or a legitimate value. The setpriority returns 0 on success and -1 on error with the errno set. |
|
16 |
|
17 The scheduling |
|
18 priority of the process, process group, or user, as indicated by which and who is obtained with the getpriority system call and set with the setpriority system call. |
|
19 The which argument |
|
20 is one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER, and who is interpreted relative to which (a process identifier for PRIO_PROCESS, process group |
|
21 identifier for PRIO_PGRP, and a user ID for PRIO_USER ). A zero value of who denotes the current process, process group, or user. |
|
22 The prio argument |
|
23 is a value in the range -20 to 20. |
|
24 The default priority is 0; |
|
25 lower priorities cause more favorable scheduling. |
|
26 |
|
27 |
|
28 |
|
29 If the prio is greater than the greatest priority supported, it is set to the greatest priority supported. |
|
30 If the prio is lesser than the least priority supported, it is set to the least priority supported. |
|
31 |
|
32 Examples: |
|
33 @code |
|
34 #include<sys/resource.h> |
|
35 #include<unistd.h> |
|
36 #include<stdio.h> |
|
37 int test_getpriority() |
|
38 { |
|
39 int retVal; |
|
40 errno = 0; |
|
41 retVal = getpriority(PRIO_PROCESS, 0); |
|
42 if((retVal == -1) && (errno == ENOSYS)) |
|
43 { |
|
44 printf("Failed"); |
|
45 return -1; |
|
46 } |
|
47 else |
|
48 { |
|
49 printf("getpriority passed"); |
|
50 printf(" |
|
51 priority = %d ", retVal); |
|
52 } |
|
53 return 0; |
|
54 } |
|
55 |
|
56 @endcode |
|
57 Output |
|
58 @code |
|
59 getpriority passed |
|
60 priority = 0 |
|
61 |
|
62 @endcode |
|
63 @code |
|
64 #include<sys/resource.h> |
|
65 #include<unistd.h> |
|
66 #include<stdio.h> |
|
67 int test_setpriority() |
|
68 { |
|
69 int retVal; |
|
70 errno = 0; |
|
71 retVal = setpriority(PRIO_PROCESS, 0, 0); |
|
72 |
|
73 if((retVal == -1) && (errno == ENOSYS)) |
|
74 { |
|
75 printf("Failed"); |
|
76 return -1; |
|
77 } |
|
78 else |
|
79 { |
|
80 printf("Setpriority passed"); |
|
81 printf(" getpriority now: %d", getpriority(PRIO_PROCESS,0)) |
|
82 } |
|
83 return 0; |
|
84 } |
|
85 |
|
86 @endcode |
|
87 Output |
|
88 @code |
|
89 Setpriority passed |
|
90 getpriority now: 0 |
|
91 |
|
92 @endcode |
|
93 |
|
94 Limitations: |
|
95 |
|
96 1. The values PRIO_PGRP and PRIO_USER for the which and any value other than 0 for who are not supported, when given return ENOSYS. |
|
97 2. To effectively increase or decrease the priority of the process, one should consider the following: |
|
98 Highest -16 to -20 Above Normal -6 to -15 Normal +4 to -5 Below Normal +14 to +5 Lowest +20 to +15 3. |
|
99 The setting of the priority to values -16 to -20 is not supported, the use of which sets errno to EINVAL. |
|
100 |
|
101 @see nice() |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 @publishedAll |
|
107 @externallyDefinedApi |
|
108 */ |
|
109 |
|
110 /** @fn setpriority(int which, int who, int value) |
|
111 @param which |
|
112 @param who |
|
113 @param value |
|
114 |
|
115 Refer to getpriority() for the documentation |
|
116 |
|
117 @see nice() |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 @publishedAll |
|
123 @externallyDefinedApi |
|
124 */ |
|
125 |
|
126 |
|
127 /** @struct rlimit |
|
128 |
|
129 Contains the following members, |
|
130 |
|
131 @publishedAll |
|
132 @externallyDefinedApi |
|
133 */ |
|
134 |
|
135 /** @var rlimit::rlim_cur |
|
136 current (soft) limit |
|
137 */ |
|
138 |
|
139 /** @var rlimit::rlim_max |
|
140 maximum value for rlim_cur |
|
141 */ |
|
142 |
|
143 /** @struct rusage |
|
144 |
|
145 Contains the following members, |
|
146 |
|
147 @publishedAll |
|
148 @externallyDefinedApi |
|
149 */ |
|
150 |
|
151 /** @var rusage::ru_utime |
|
152 user time used |
|
153 */ |
|
154 |
|
155 /** @var rusage::ru_stime |
|
156 system time used |
|
157 */ |
|
158 |
|
159 /** @var rusage::ru_maxrss |
|
160 max resident set size |
|
161 */ |
|
162 |
|
163 /** @var rusage::ru_ixrss |
|
164 integral shared memory size |
|
165 */ |
|
166 |
|
167 /** @var rusage::ru_idrss |
|
168 integral unshared data |
|
169 */ |
|
170 |
|
171 /** @var rusage::ru_isrss |
|
172 integral unshared stack |
|
173 */ |
|
174 |
|
175 /** @var rusage::ru_minflt |
|
176 page reclaims |
|
177 */ |
|
178 |
|
179 /** @var rusage::ru_majflt |
|
180 page faults |
|
181 */ |
|
182 |
|
183 /** @var rusage::ru_nswap |
|
184 (c + j) swaps |
|
185 */ |
|
186 |
|
187 /** @var rusage::ru_inblock |
|
188 block input operations |
|
189 */ |
|
190 |
|
191 /** @var rusage::ru_oublock |
|
192 block output operations |
|
193 */ |
|
194 |
|
195 /** @var rusage::ru_msgsnd |
|
196 messages sent |
|
197 */ |
|
198 |
|
199 /** @var rusage::ru_msgrcv |
|
200 messages received |
|
201 */ |
|
202 |
|
203 /** @var rusage::ru_nsignals |
|
204 signals received |
|
205 */ |
|
206 |
|
207 /** @var rusage::ru_nvcsw |
|
208 voluntary context switches |
|
209 */ |
|
210 |
|
211 /** @var rusage::ru_nivcsw |
|
212 involuntary |
|
213 */ |
|
214 |
|
215 |
|
216 /** @typedef typedef __rlim_t rlim_t |
|
217 |
|
218 Unsigned integer type used for limit values. |
|
219 |
|
220 @publishedAll |
|
221 @externallyDefinedApi |
|
222 */ |
|
223 |
|
224 |
|
225 /** @def RLIM_INFINITY |
|
226 |
|
227 unsigned long int |
|
228 |
|
229 @publishedAll |
|
230 @externallyDefinedApi |
|
231 */ |
|
232 |
|
233 /** @def RLIMIT_CORE |
|
234 |
|
235 core file size |
|
236 |
|
237 @publishedAll |
|
238 @externallyDefinedApi |
|
239 */ |
|
240 |
|
241 /** @def RLIMIT_CPU |
|
242 |
|
243 cpu time in milliseconds |
|
244 |
|
245 @publishedAll |
|
246 @externallyDefinedApi |
|
247 */ |
|
248 |
|
249 /** @def RLIMIT_DATA |
|
250 |
|
251 data size |
|
252 |
|
253 @publishedAll |
|
254 @externallyDefinedApi |
|
255 */ |
|
256 |
|
257 /** @def RLIMIT_FSIZE |
|
258 |
|
259 maximum file size |
|
260 |
|
261 @publishedAll |
|
262 @externallyDefinedApi |
|
263 */ |
|
264 |
|
265 |
|
266 /** @def RLIMIT_NOFILE |
|
267 |
|
268 number of open files |
|
269 |
|
270 @publishedAll |
|
271 @externallyDefinedApi |
|
272 */ |
|
273 |
|
274 /** @def RLIMIT_STACK |
|
275 |
|
276 stack size |
|
277 |
|
278 @publishedAll |
|
279 @externallyDefinedApi |
|
280 */ |
|
281 |
|
282 /** @def RLIMIT_AS |
|
283 |
|
284 standard name for RLIMIT_VMEM |
|
285 |
|
286 @publishedAll |
|
287 @externallyDefinedApi |
|
288 */ |
|
289 |
|
290 /** @def RUSAGE_SELF |
|
291 |
|
292 Resource utilization information. |
|
293 |
|
294 @publishedAll |
|
295 @externallyDefinedApi |
|
296 */ |
|
297 |
|
298 /** @def RUSAGE_CHILDREN |
|
299 |
|
300 Resource utilization information. |
|
301 |
|
302 @publishedAll |
|
303 @externallyDefinedApi |
|
304 */ |
|
305 |
|
306 |
|
307 /** @def PRIO_PROCESS |
|
308 |
|
309 Process priority specifications to get or set priority. |
|
310 |
|
311 @publishedAll |
|
312 @externallyDefinedApi |
|
313 */ |
|
314 |
|
315 /** @def PRIO_PGRP |
|
316 |
|
317 Process priority specifications to get or set priority. |
|
318 |
|
319 @publishedAll |
|
320 @externallyDefinedApi |
|
321 */ |
|
322 |
|
323 /** @def PRIO_USER |
|
324 |
|
325 Process priority specifications to get or set priority. |
|
326 |
|
327 @publishedAll |
|
328 @externallyDefinedApi |
|
329 */ |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |