linux 中 timeval结构体 - Neddy11 - 博客园
2013-11-11 11:24
134 查看
linux 中 timeval结构体 - Neddy11 - 博客园
linux 中 timeval结构体网上很多人写到,timeval结构解释错误
*******************************************************************
问题如下:
在debian linux的man页中对gettimeofday函数的说明中,有这样一个说明:
DESCRIPTION
The functions gettimeofday and settimeofday can get and set the time as
well as a timezone. The tv argument is a timeval struct, as specified
in <sys/time.h>:
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
其中对tv_usec的说明为时间的毫秒部分。 而在实际中,该函数以及Linux内核返回的timeval
类型的时间值,tv_usec代表的是微秒精度(10的-6次方秒)。
********************************************************************
我很无语,只能说写这话的人英语很水,microsecond 是微秒的意思,简写为usec
毫秒的英语单词是millisecond,简写为msec
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
int main(int argc,char * argv[])
{
struct timeval tv;
while(1)
{
gettimeofday(&tv,NULL);
printf("time %u:%u\n",tv.tv_sec,tv.tv_usec);
sleep(2);
}
return 0;
}
*******************************************************************
问题如下:
在debian linux的man页中对gettimeofday函数的说明中,有这样一个说明:
DESCRIPTION
The functions gettimeofday and settimeofday can get and set the time as
well as a timezone. The tv argument is a timeval struct, as specified
in <sys/time.h>:
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
其中对tv_usec的说明为时间的毫秒部分。 而在实际中,该函数以及Linux内核返回的timeval
类型的时间值,tv_usec代表的是微秒精度(10的-6次方秒)。
********************************************************************
我很无语,只能说写这话的人英语很水,microsecond 是微秒的意思,简写为usec
毫秒的英语单词是millisecond,简写为msec
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
int main(int argc,char * argv[])
{
struct timeval tv;
while(1)
{
gettimeofday(&tv,NULL);
printf("time %u:%u\n",tv.tv_sec,tv.tv_usec);
sleep(2);
}
return 0;
}
相关文章推荐
- Linux下jdk安装、环境变量的配置
- CentOS 配置mysql允许远程登录
- linux install&access Nessus-5.2.4
- 查看linux版本
- Linux编辑环境vim插件:taglist
- DDOS攻击以及预防
- Linux编辑环境vim插件:ctags
- Linux文件夹及权限
- VirtualBox中安装x64的Linux System
- Linux下的/lost found目录
- struct ifreq结构体与ip,子网掩码,网关等信息
- 嵌入式Linux系统中的.lds链接脚本基础
- Linux 标准目录结构
- syslogd和klogd
- 在Linux-2.6.32.2下为ST16C554移植驱动的经历
- centos 6.3 搭建svn
- linux apt-get和yum
- linux中apt命令介绍
- linux-文件和目录操作
- linux vi的使用