Linux下给get,linux下getrusage()

本文详细介绍了Linux系统调用getrusage的作用和使用,该函数用于获取指定进程的资源使用信息,包括用户时间、系统时间、内存使用等详细指标。同时,解释了rusage结构体中的各项成员,如utime、stime、maxrss等,帮助理解进程的资源消耗情况。
摘要由CSDN通过智能技术生成

#include

/* 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

/* 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;

};

原文:http://www.cnblogs.com/xianzhedeyu/p/3516546.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值