#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. Windows Phone 选择器

    using Microsoft.Phone.Controls; using Microsoft.Phone.Tasks; using System; using System.Windows; nam ...

  2. NSIS API 函数常用备份

    原文:NSIS API 函数常用备份 关闭程序: System::Call `user32::AnimateWindow(i$HWNDPARENT,i200,i${AW_BLEND}|${AW_HID ...

  3. java NIO中的Reactor相关知识汇总 (转)

    一.引子 nio是java的IO框架里边十分重要的一部分内容,其最核心的就是提供了非阻塞IO的处理方式,最典型的应用场景就是处理网络连接.很多同学提起nio都能说起一二,但是细究其背后的原理.思想往往 ...

  4. Oracle 实现 mysql 的 find_in_set 排序!

    oracle 实现类似MYSQL的 find_in_set 排序,函数 decode: select * from tb_info_game where gameid in(23,20,19,26,1 ...

  5. Cocos2dx 3.0 交流篇

    创建项目: For(MAC) Runtime Requirements Android 2.3 or newer iOS 5.0 or newer OS X 10.7 or newer Windows ...

  6. SQL Server编程系列(2):SMO常用对象的有关操作

    原文:SQL Server编程系列(2):SMO常用对象的有关操作 在上一篇周公简单讲述了SMO的一些基本概念,实际上SMO体系结构远不止周公在上一篇中讲述的那么简单,下图是MSDN上给出的一个完整的 ...

  7. VC各种方法获得的窗口句柄

    AfxGetMainWnd AfxGetMainWnd获取窗口句柄本身 HWND hWnd = AfxGetMainWnd()->m_hWnd; GetTopWindow 功能:子窗体z序(Z序 ...

  8. swift 注意事项 (十六) —— 可选链

    可选链(Optional Chaining) 我们都知道"可选型"是什么.那么可选链又是什么,举个样例解释一下: struct MyName{      var name } st ...

  9. —软测试—(5)计算机系统CPU组成

    事实上,我们不得不很早就接触到电脑系统的知识,但仍然会出现不起眼,现象清醒的认识,非常严重丢分. 要我们花功夫去理解,由于非常多东西我们接触不到,比方校验码.码制等.假设你不去理解而是去记,就非常难參 ...

  10. vs2012 + web api + OData + EF + MYsql

    vs2012 + web api + OData + EF + MYsql 开发及部署 先说下我的情况,b/s开发这块已经很久没有搞了,什么web api .MVC.OData都只是听过,没有实际开发 ...