����14-30 linux/include/sys/resource.h
1 /*
2 * Resource control/accounting header file for linux
3 */
/*
* Linux��Դ����/���ͷ�ļ���
4
5 #ifndef _SYS_RESOURCE_H
6 #define _SYS_RESOURCE_H
7
// ���·��ų����ͽṹ����getrusage()���μ�kernel/sys.c�ļ���412�п�ʼ��
8 /*
9 * Definition of struct rusage taken from BSD 4.3 Reno
10 *
11 * We don't support all of these yet, but we might as well have them....
12 * Otherwise, each time we add new items, programs which depend on this
13 * structure will lose. This reduces the chances of that happening.
14 */
/*
* rusage�ṹ�Ķ���ȡ��BSD 4.3 Renoϵͳ��
*
* �������ڻ�û��֧�ָýṹ�е�������Щ�ֶΣ������ǿ��ܻ�֧�����ǵ�....
* ����Ļ���ÿ�����������µ��ֶΣ���Щ����������ṹ�ij���ͻ�����⡣
* ���ڰ������ֶζ����������Ϳ��Ա����������鷢����
*/
// ������getrusage()�IJ���who��ʹ�õķ��ų�����
15 #define RUSAGE_SELF 0 // ���ص�ǰ���̵���Դ������Ϣ��
16 #define RUSAGE_CHILDREN -1 // ���ص�ǰ��������ֹ�͵ȴ��ŵ��ӽ��̵���Դ������Ϣ��
17
// rusage�ǽ��̵���Դ����ͳ�ƽṹ������getrusage()����ָ�����̶���Դ���õ�ͳ��ֵ��
// Linux 0.12�ں˽�ʹ����ǰ�����ֶΣ����Ƕ���timeval�ṹ��include/sys/time.h����
// ru_utime �C �������û�̬����ʱ��ͳ��ֵ��ru_stime �C �������ں�̬����ʱ��ͳ��ֵ��
18 struct rusage {
19 struct timeval ru_utime; /* user time used */
20 struct timeval ru_stime; /* system time used */
21 long ru_maxrss; /* maximum resident set size */
22 long ru_ixrss; /* integral shared memory size */
23 long ru_idrss; /* integral unshared data size */
24 long ru_isrss; /* integral unshared stack size */
25 long ru_minflt; /* page reclaims */
26 long ru_majflt; /* page faults */
27 long ru_nswap; /* swaps */
28 long ru_inblock; /* block input operations */
29 long ru_oublock; /* block output operations */
30 long ru_msgsnd; /* messages sent */
31 long ru_msgrcv; /* messages received */
32 long ru_nsignals; /* signals received */
33 long ru_nvcsw; /* voluntary context switches */
34 long ru_nivcsw; /* involuntary " */
35 };
36
// ������getrlimit()��setrlimit()ʹ�õķ��ų����ͽṹ��
37 /*
38 * Resource limits
39 */
/*
* ��Դ���ơ�
*/
// ������Linux 0.12�ں������������Դ���࣬��getrlimit()��setrlimit()�е�1������
// resource ��ȡֵ��Χ�� ��ʵ��Щ���ų������ǽ�������ṹ�� rlim[] �����������ֵ��
// rlim[]�����ÿһ���һ��rlimit�ṹ���ýṹ�������58�С�
40
41 #define RLIMIT_CPU 0 /* CPU time in ms */ /* ʹ�õ�CPUʱ�� */
42 #define RLIMIT_FSIZE 1 /* Maximum filesize */ /* �������� */
43 #define RLIMIT_DATA 2 /* max data size */ /* ������ݳ��� */
44 #define RLIMIT_STACK 3 /* max stack size */ /* ���ջ���� */
45 #define RLIMIT_CORE 4 /* max core file size */ /* ���core����� */
46 #define RLIMIT_RSS 5 /* max resident set size */ /* ���פ������С */
47
// ��������˷���notdef����Ҳ�������·��ų������塣
48 #ifdef notdef
49 #define RLIMIT_MEMLOCK 6 /* max locked-in-memory address space*/ /* ������ */
50 #define RLIMIT_NPROC 7 /* max number of processes */ /* ����ӽ����� */
51 #define RLIMIT_OFILE 8 /* max number of open files */ /* ������� */
52 #endif
53
// ������ų���������Linux�����Ƶ���Դ���ࡣRLIM_NLIMITS=6����˽�ǰ��6����Ч��
54 #define RLIM_NLIMITS 6
55
// ��ʾ��Դ���ޣ������ġ�
56 #define RLIM_INFINITY 0x7fffffff
57
// ��Դ���ṹ��
58 struct rlimit {
59 int rlim_cur; // ��ǰ��Դ���ƣ���������ƣ�soft limit����
60 int rlim_max; // Ӳ���ƣ�hard limit����
61 };
62
63 #endif /* _SYS_RESOURCE_H */
64