getrusage.2
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 162 行
2
162 行
.\" SCCSID: @(#)getrusage.2 8.1 9/11/90.TH getrusage 2.SH Namegetrusage \- get information about resource utilization.SH Syntax.nf.ft B#include <sys/time.h>#include <sys/resource.h>.PP.ft B.ta \w'#define 'u +\w'RUSAGE_CHILDREN 'u +\w'-1 'u#define RUSAGE_SELF 0 /* calling process */#define RUSAGE_CHILDREN -1 /* terminated child processes */.DT.PP.ft Bgetrusage(who, rusage)int who;struct rusage *rusage;.fi.SH Description.NXB "getrusage system call".NXR "process" "getting information about resource utilization"The.PN getrusagesystem callreturns information describing the resources utilized by the currentprocess or all its terminated child processes.The.I whoparameter is one of RUSAGE_SELF and RUSAGE_CHILDREN.If.I rusageis nonzero, the buffer it points to will be filled in withthe following structure:.EX 0struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ int ru_maxrss; int ru_ixrss; /* integral shared text size */ int ru_ismrss /* integral shared memory size */ int ru_idrss; /* integral unshared data size */ int ru_isrss; /* integral unshared stack size */ int ru_minflt; /* page reclaims */ int ru_majflt; /* page faults */ int ru_nswap; /* swaps */ int ru_inblock; /* block input operations */ int ru_oublock; /* block output operations */ int ru_msgsnd; /* messages sent */ int ru_msgrcv; /* messages received */ int ru_nsignals; /* signals received */ int ru_nvcsw; /* voluntary context switches */ int ru_nivcsw; /* involuntary context switches */};.EE.PPThe fields are interpreted as follows:.NXB "getrusage system call" "fields".TP.I ru_utimeThe total amount of time spent executing in user mode..TP.I ru_stimeThe total amount of time spent in the system executing on behalfof the processes..TP.I ru_maxrssThe maximum resident set size utilized (in bytes)..TP.I ru_ixrssAn \*(lqintegral\*(rq value indicating the amount of text memory usedthat was also shared among other processes. This value is expressedin units of kilobytes * seconds-of-execution and is calculated bysumming the number of shared memory pages in use each time the internalsystem clock ticks and then averaging over 1-second intervals..TP.I ru_ismrssAn integral value of the amount of shared memory residing in the datasegment of a process (expressed in units of kilobytes *seconds-of execution)..TP.I ru_idrssAn integral value of the amount of unshared memory residing in thedata segment of a process (expressed in units ofkilobytes * seconds-of-execution)..TP.I ru_isrssAn integral value of the amount of unshared memory residing in thestack segment of a process (expressed in units ofkilobytes * seconds-of-execution)..TP.I ru_minfltThe number of page faults serviced without any I/O activity; here,I/O activity is avoided by \*(lqreclaiming\*(rq a page frame fromthe list of pages awaiting reallocation..TP.I ru_majfltThe number of page faults serviced that required I/O activity..TP.I ru_nswapThe number of times a process was \*(lqswapped\*(rq out of mainmemory..TP.I ru_inblockThe number of times the file system had to perform input..TP.I ru_oublockThe number of times the file system had to perform output..TP.I ru_msgsndThe number of ipc messages sent..TP.I ru_msgrcvThe number of ipc messages received..TP.I ru_nsignalsThe number of signals delivered..TP.I ru_nvcswThe number of times a context switch resulted due to a processvoluntarily giving up the processor before its time slice wascompleted, usually to await availability of a resource..TP.I ru_nivcswThe number of times a context switch resulted due to a higherpriority process becoming runnable or because the current processexceeded its time slice..NXE "getrusage system call" "fields".PPThe numbers .I ru_inblock and .I ru_oublock account only for realI/O. Data supplied by the cacheing mechanism is charged onlyto the first process to read or write the data..SH Restrictions.NXR "getrusage system call" "restricted"There is no way to obtain information about a child processthat has not yet terminated..SH Diagnostics.NXR "getrusage system call" "diagnostics"The .PN getrusagecall fails under the following conditions:.TP 15[EINVAL]The.I whoparameter is not a valid value on RUSAGE_SELF or RUSAGE_CHILDREN..TP[EFAULT]The address specified by the.I rusageparameter is not in a valid part of the process addressspace..SH See Alsogettimeofday(2), wait(2).NXE "getrusage system call"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?