linux内核延时不精准,gettimeofday

相关讨论

我用gettimeofday在linux(2.4.21-37.ELsmp)上计算时间差,下面是部分代码

struct timeval tvStart,tvEnd;

double linStart = 0,linEnd = 0,lTime = 0;

gettimeofday (&tvStart,NULL);

//do something

gettimeofday (&tvEnd,NULL);

linStart = ((double)tvStart.tv_sec * 1000000 + (double)tvStart.tv_usec); //unit S

linEnd = ((double)tvEnd.tv_sec * 1000000 + (double)tvEnd.tv_usec); //unit S

...

by

haohao06

-

C/C++

-

2012-04-26 16:27:50阅读(52372) 回复(17)

不知道发到这个版问合适吗?

solaris、llinux有497日jiffies溢出的问题,

如果一个程序没有直接使用jiffies,而是有调用gettimeofday,time之类的时间函数,

要考虑jiffies溢出的问题吗?

gettimeofday,time这些函数本身应该是已经避免了这个溢出问题吧?

by

penpals

-

C/C++

-

2010-12-30 15:30:41阅读(2180) 回复(0)

内核是2.6.15.4,想学习一下劫持内核函数的方法,于是写了一个模块劫持

arch/i386/kernel/time.c中的do_gettimeofday函数,

模块编译通过但是一旦加载就死机,

是因为此函数不能被劫持还是模块编写的有问题呢?

那位前辈大哥帮忙看看,不胜感激!!!!

#include #include #include #include #include #include #include

by

wuhuaguoshu

-

内核/嵌入技术

-

2006-05-12 15:39:35阅读(4919) 回复(11)

内核是2.6.15.4,想学习一下劫持内核函数的方法,于是写了一个模块劫持

arch/i386/kernel/time.c中的do_gettimeofday函数,

模块编译通过但是一旦加载就死机,

是因为此函数不能被劫持还是模块编写的有问题呢?

那位前辈大哥帮忙看看,不胜感激!!!!

#include #include #include #include #include #include #include

by

wuhuaguoshu

-

内核源码

-

2006-05-12 15:39:35阅读(4358) 回复(11)

by

ydfgic

-

C/C++

-

2014-02-14 20:39:37阅读(17934) 回复(13)

#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阅读(1719) 回复(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阅读(1042) 回复(0)

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

by

twen345

-

C/C++

-

2011-03-04 20:22:07阅读(2687) 回复(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阅读(881) 回复(0)

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

by

boxerw

-

C/C++

-

2010-09-09 21:34:33阅读(5250) 回复(7)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值