linux下getrusage()

系统 1883 0

#include <sys/resource.h>

/* Return resource usage information on process indicated by WHO
and put it in *USAGE. Returns 0 for success, -1 for failure. */
extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;

参数: 

who:可能选择有

  RUSAGE_SELF:获取当前进程的资源使用信息。

  RUSAGE_CHILDREN:获取子进程的资源使用信息。

usage:指向存放资源使用信息的结构指针

#include <bits/resources.>

/* Structure which says how much of each resource has been used. */
struct rusage
{
 /* Total amount of user time used. */
 struct timeval ru_utime;
 /* Total amount of system time used. */
 struct timeval ru_stime;
 /* Maximum resident set size (in kilobytes). */
 long int ru_maxrss;
 /* Amount of sharing of text segment memory
 with other processes (kilobyte-seconds). */
 long int ru_ixrss;
 /* Amount of data segment memory used (kilobyte-seconds). */
 long int ru_idrss;
 /* Amount of stack memory used (kilobyte-seconds). */
 long int ru_isrss;
 /* Number of soft page faults (i.e. those serviced by reclaiming
 a page from the list of pages awaiting reallocation. */
 long int ru_minflt;
 /* Number of hard page faults (i.e. those that required I/O). */
 long int ru_majflt;
 /* Number of times a process was swapped out of physical memory. */
 long int ru_nswap;
 /* Number of input operations via the file system. Note: This
 and `ru_oublock' do not include operations with the cache. */
 long int ru_inblock;
 /* Number of output operations via the file system. */
 long int ru_oublock;
 /* Number of IPC messages sent. */
 long int ru_msgsnd;
 /* Number of IPC messages received. */
 long int ru_msgrcv;
 /* Number of signals delivered. */
long int ru_nsignals;
/* Number of voluntary context switches, i.e. because the process
gave up the process before it had to (usually to wait for some
resource to be available). */
long int ru_nvcsw;
/* Number of involuntary context switches, i.e. a higher priority process

became runnable or the current process used up its time slice. */
 long int ru_nivcsw;
 };

 

linux下getrusage()


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论