#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()的更多相关文章

  1. NodeJs在Linux下使用的各种问题

    环境:ubuntu16.04 ubuntu中安装NodeJs 通过apt-get命令安装后发现只能使用nodejs,而没有node命令 如果想避免这种情况请看下面连接的这种安装方式: 拓展见:Linu ...

  2. Linux下服务器端开发流程及相关工具介绍(C++)

    去年刚毕业来公司后,做为新人,发现很多东西都没有文档,各种工具和地址都是口口相传的,而且很多时候都是不知道有哪些工具可以使用,所以当时就想把自己接触到的这些东西记录下来,为后来者提供参考,相当于一个路 ...

  3. Linux下Nodejs安装(完整详细)

    之前安装过windows下以及Mac下的node,感觉还是很方便的,不成想今天安装linux下的坑了老半天,特此记录. 首先去官网下载代码,这里一定要注意安装分两种,一种是Source Code源码, ...

  4. (转载)linux下各个文件夹的作用

    linux下的文件结构,看看每个文件夹都是干吗用的/bin 二进制可执行命令 /dev 设备特殊文件 /etc 系统管理和配置文件 /etc/rc.d 启动的配置文件和脚本 /home 用户主目录的基 ...

  5. 萌新笔记——linux下查看内存的使用情况

    windows上有各种软件可以进行"一键加速"之类的操作,释放掉一些内存(虽然我暂时不知道是怎么办到的,有待后续学习).而任务管理器也可以很方便地查看各进程使用的内存情况,如下图: ...

  6. [每日Linux]Linux下xsell和xftp的使用

    实验缘由: 1.xsell在Linux下的作用就是远程登录的一个界面,也就是实现访问在Windows下访问Linux服务器的功能.之前在数据挖掘实验中因为自己电脑的内存不够,曾经使用过实验室的服务器跑 ...

  7. Linux下的C Socket编程 -- server端的继续研究

    Linux下的C Socket编程(四) 延长server的生命周期 在前面的一个个例子中,server在处理完一个连接后便会立即结束掉自己,然而这种server并不科学啊,server应该是能够一直 ...

  8. 我将系统从Windows迁移至Linux下的点点滴滴

    一.写在最前 由于本人的技术水平有限,难免会出现错误.本文对任何一个人有帮助都是我莫大的荣幸,任何一个大神对我的点拨,我都会感激不尽. 二.技术选型 在2013年8月低的时候,公司中了XXX市场监督局 ...

  9. linux下mono播放PCM音频

         测试环境: Ubuntu 14 MonoDevelop CodeBlocks 1.建立一个共享库(shared library) 这里用到了linux下的音频播放库,alsa-lib. al ...

随机推荐

  1. SQL入门学习0-数据库与SQL

    1.1 DBMS DatabaseManagermentSystem 数据库管理系统 DBMS种类 层次型数据库(HDB) 最古老的数据库之一,把数据通过层次结构的方式表现. 关系型数据库(RDB) ...

  2. emacs quick open and jump file (or buffer) which name is current word

    Sometime, we need to open a file or buffer which name begin with current word in emacs. Here I give ...

  3. HTML基金会2----联系,像, 第,对齐

    ios讨论组1团:135718460 在web开发中.排版,布局非常重要,因此我们要把基础的东西打坚固,大家不要 慌,慢慢来. 直接把代码拿过去,直接就能够执行的. 1.标题 2.段落 3.HTML ...

  4. DTD验证XML(转)

    1.内部DTD       最简单的使用DTD的方法是在XML文件的序言部分加入一个DTD描述,加入的位置是紧接在XML处理指示之后.一个包含DTD的XML文件的结构为:    <?xml ve ...

  5. web开发性能优化---UI接口章

    1.尽可能的远div+css设计 DIV+CSS与表相比格优势布局: a.精简代码 采用DIV+CSS设计,页面代码精简.这是为了XHTML了解都知道. 代码精简所带来的直接优点有两点:一是提高蜘蛛爬 ...

  6. Android pm命令用法

    Sam综观有关PackageManager时,无意中发现Android 下提供一个pm命令,通常放在/system/bin/下. 这个命令与Package有关.且很有用.所以研究之. 0. Usage ...

  7. java Map 之 排序(key,value)

    一:起因: (1)现实中须要Map容器进行排序的情况非常多非常多:由于Map<key,value>键值对的存储结构特别是HashMap的结构是非常优秀的,数据存储就难免对其进行排序: (2 ...

  8. ubuntu12.04下一个samba、tftp、nfs构造

    1.samba setting   1>apt-get install samba     apt-get install smbfs   2>mkdir /home/linux/shar ...

  9. Oracle 指数 一个简短的引论

    1 索引创建语法: CREATE UNIUQE | BITMAP INDEX <schema>.<index_name>       ON <schema>.< ...

  10. Codeforces 328B-Sheldon and Ice Pieces(馋)

    B. Sheldon and Ice Pieces time limit per test 1 second memory limit per test 256 megabytes input sta ...