首页 | 资讯动态 | linux基础 | 系统管理 | 网络管理 | 编程开发 | linux数据库 | 服务器技术 | linux相关 | linux认证 | 嵌入式 | 下载中心 | 专题 | linux招聘 | 镜像站
OKLinux中文技术站
·设为首页
·加入收藏
·联系我们
系统管理: 中文环境 系统管理 桌面应用 内核技术 | Linux基础: 基础入门 安装配置 常用命令 经验技巧 软件应用 | Linux数据库: Mysql Postgre Oracle DB2 Sybase other
网络管理: 网络安全 网络应用 Linux服务器 环境配置 黑客安全 | 编程开发: PHP CC++ Python Perl Shell 嵌入式开发 java jsp | PHP技术: PHP基础 PHP技巧 PHP应用 PHP文摘
搜索中心 Linux招聘 Linux专题 Apache | Linux相关: 硬件相关 Linux解决方案 Linux认证 企业应用 其它Unix | 相关下载: 资料下载 参考手册 开发工具 服务器类 软路由 其它
 技术搜索:
会员中心 注册会员 高级搜索  
  → 当前位置:首页>编程开发>其他编程>正文

Linux中的GetTickCount

http://www.oklinux.cn  2008-09-11  linuxidc   会员收藏  游客收藏  【 】 
您查看的文章来源于http://www.oklinux.cn

Windows中的GetTickCount非常好用,到了Linux下,我一开始还真没找到替代函数(有点菜),当时恰好项目中的一个模块要用到这个功能,我只好用了gettimeofday来间接满足了要求,但这并不是真正的系统启动后运行的时间。

前几天Review代码,觉得有必要再去研究一下,嘿嘿,还真发现了。

SYSINFO(2) Linux Programmer’s Manual SYSINFO(2)

NAME
sysinfo - returns information on overall system statistics

SYNOPSIS
#include <sys/sysinfo.h>

int sysinfo(struct sysinfo *info);

DESCRIPTION
Until Linux 2.3.16, sysinfo() used to return information in
the following structure:

struct sysinfo {
long uptime; /* Seconds since boot */
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
unsigned long totalram; /* Total usable main memory size */
unsigned long freeram; /* Available memory size */
unsigned long sharedram; /* Amount of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
char _f[22]; /* Pads structure to 64 bytes */
};

and the sizes were given in bytes.

Since Linux 2.3.23 (i386), 2.3.48 (all architectures) the
structure is:

struct sysinfo {
long uptime; /* Seconds since boot */
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
unsigned long totalram; /* Total usable main memory size */
unsigned long freeram; /* Available memory size */
unsigned long sharedram; /* Amount of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
unsigned long totalhigh; /* Total high memory size */
unsigned long freehigh; /* Available high memory size */
unsigned int mem_unit; /* Memory unit size in bytes */
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding for libc5 */
};

and the sizes are given as multiples of mem_unit bytes.

sysinfo() provides a simple way of getting overall system
statistics. This is more portable than reading /dev/kmem.
For an example of its use, see intro(2).

RETURN VALUE
On success, zero is returned. On error, -1 is returned, and
errno is set appropriately.

ERRORS
EFAULT pointer to struct sysinfo is invalid

CONFORMING TO
This function is Linux specific, and should not be used in
programs intended to be portable.

The Linux kernel has a sysinfo() system call since 0.98.pl6.
Linux libc contains a sysinfo() routine since 5.3.5, and glibc
has one since 1.90.

SEE ALSO
proc(5)


Linux 1997-08-25 SYSINFO(2)


上一篇:Linux下ImageMagick和JMagick的安装整理   下一篇:Linux源码学习--bootsect.s启动

收藏于收藏夹】 【评论】 【推荐】 【打印】 【关闭
相关文档
·Linux源码学习--bootsect.s启动
·Linux下ImageMagick和JMagick的安装整理
·Linux开发初探
·用Linux命令行实现批量文件编码转换
·vxworks与Linux内核比较
·更换Linux内核版本
·Linux下编译出来的动态链接库缺少so后缀的问题解决
·Linux下JRE不显示中文解决办法
·嵌入式Linux内核的交叉编译编译-基于2.6.26
·交叉编译uim 1.5.2 for pdaxrom
·Linux的文件处理挺强挺厉害
·在编写Linux下的gtk程序的时候遇到的问题
·升级Linux2.4.9内核到2.6.26.3版
·Linux Shell下一些有用的快捷键
·Linux下使用PHP时由参数“b”的想到的
·Linux下使用dirname命令
发表评论
密码: 匿名评论
评论内容:

(不超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)
 
  最新文档
·Linux源码学习--bootsect.s启动
·Linux下ImageMagick和JMagick的安装整
·Linux开发初探
·用Linux命令行实现批量文件编码转换
·vxworks与Linux内核比较
·更换Linux内核版本
·Linux下编译出来的动态链接库缺少so后
·Linux下JRE不显示中文解决办法
·嵌入式Linux内核的交叉编译编译-基于2
·交叉编译uim 1.5.2 for pdaxrom
·Linux的文件处理挺强挺厉害
·在编写Linux下的gtk程序的时候遇到的问
  阅读排行
·Linux下Qtopia Core 4.3(QT/E)交叉编译
·开源空间 网络安全工具开发函数库Libne
·Linux编程时获取当前时间实例解析
·Linux环境下OpenGL编程学习
·Linux socket编程实例:echo服务器程序
·升级Redhat Linux 9.0内核有感
·Linux中断处理学习笔记
·GNU/Linux应用程序编程:用管道进行编
·Linux系统中限制用户进程CPU及内存占用
·Linux下安装g77 fortran complier过程
·Linux环境下重新编译GCC-4.3.0
·解决Linux中Matlab中文乱码问题
·Linux环境下Wine的中文显示以及freetyp
·Linux多线程编程学习之线程同步
·SUSE Linux中安装Quartus 7.2过程笔记
网摘收藏: