ChinaUnix.net
相关文章推荐:

gettimeofday 4398

#include stdlib.h> #include stdio.h> #include unistd.h> #include string.h> #include time.h> #include sys/time.h> #define err(msg) perror(msg) int main(void) { struct timeval tv, tv2; struct tm *tm; time_t newtime; if (gettimeofday(&tv, NULL) == -1) { err("gettimeofday"); goto out; } if ((tm = localtime(&tv.tv_...

by @sky - Linux文档专区 - 2009-12-08 22:14:38 阅读(1725) 回复(0)

相关讨论

In the time subsystem, gettimeofday() always return current wall time. The wall time is expected to record the real world time. But in arm architecture, it happily gives you a biased wall time. When time goes on, the value is far from the real world time. Lets look at how gettimeofday() is implemented. Firstly gettimeofday() is called in the user application. And then: 1. it calls sys_getti...

by superfluous - Linux文档专区 - 2009-08-10 11:28:38 阅读(1045) 回复(0)

linux内核的时钟中断是10ms,但gettimeofday 的返回值能精确到微秒,这是怎么实现的呢?百思不得其解 :em14:

by twen345 - C/C++ - 2011-03-04 20:22:07 阅读(2689) 回复(7)

(continued) Now Let's look back our deduction. We get the correct time if we get the right last_time. If the last_time is incorrect, how can we get the real world time? The last_time is based on timer interrupt. The timer, which is as a primitive source to drive the whole system, is architecture-specific. Usually it is located on PIT of the spcific architecture. In our example it is AT91SAM9263's ...

by superfluous - Linux文档专区 - 2009-08-11 10:02:49 阅读(884) 回复(0)

gettimeofday取到的微秒是精确么?貌似和cup的主频有关:shock:

by boxerw - C/C++ - 2010-09-09 21:34:33 阅读(5254) 回复(7)

Actually, VxWorks can use the following thing to replace gettimeofday. struct timespec tp; ret = clock_gettime(CLOCK_REALTIME, &tp); srand( tp.tv_sec+tp.tv_nsec); However, you can implement gettimeofday as following int gettimeofday(struct timeval *tv, struct timezone *tz) { int ret; struct timespec tp; if ( (ret=clock_gettime(CLOCK_REALTIME, &tp))==0) { tv->tv...

by soararing - 嵌入式开发 - 2009-05-05 10:34:57 阅读(3730) 回复(0)

文件: tracksettimeofday.rar 大小: 3KB 下载: 下载 有个通用模块记录日志,当然也包含时间了。但是在客户那边运行,总是每隔一段时间,会出现一次获取的时间跳到未来1小时13或1小时14分之后,然后马上又正常了。但是在我们内部环境没有出现。 开始以为是ntpd同步时间的同时,可能导致时间不一致。但是停掉ntpd,问题依然。 然后又估计可能是有进程设置时间瞬间,导致时间差异,做了个lkm来监控settimeofday。监控日志也没发现什...

by gadfly - Linux文档专区 - 2008-10-15 15:26:36 阅读(2251) 回复(0)

做了一个通讯延时的测试 A每隔10S向B发一个消息 B记录各消息之间的时间间隔 我在同一台机子上测试时,时间间隔在10S左右 但是,把A和B运行在不同的机子上时时间间隔有很大的变化 有的是4S左右,有的是20S左右 好象在哪看到过说这个函数计时不准确,但具体不知道是怎么回事了 麻烦高手指点一下

by Ediml - C/C++ - 2008-06-16 19:48:38 阅读(3707) 回复(1)

the sysdate should be easily transplant to string type! is there any system call like that in unix system?? thank you for your help!!

by fxhnkf - C/C++ - 2005-05-07 10:49:48 阅读(1253) 回复(8)
by yanghehe - C/C++ - 2007-12-21 17:02:54 阅读(9548) 回复(5)

ULK中对gettimeofday的实现介绍: get_timeofday: 1.usec=cur_timer->getoffset(); 2. 如果某定时器中断丢失则:usec += (jiffies - wall_jiffies) * 1000; 3. usec += (xtime.tv_nsec / 1000); 4. tv->tv_sec = xtime->sec; tv->tv_usec = usec 为什么tv->tv_usec不用取当前xtime.tv_nsec / 1000直接...

by suenway - 内核源码 - 2011-11-28 12:46:03 阅读(3797) 回复(7)