login
Header Space

 
 

get time inside kernel

March 26, 2006 - 11:25am
Submitted by Anonymous on March 26, 2006 - 11:25am.
Linux

Hi,

I would like to get time marks inside my module. I see time syscall, but it returns seconds and I would like a more fine scale (like mili-seconds)
Is it possible?

Thanks in advance.

Looking at a recent include/l

March 26, 2006 - 1:55pm

Looking at a recent include/linux/time.h will show you that you can call

current_kernel_time()

or

CURRENT_TIME()

to get a timespec that goes down to nanoseconds.



I am not sure what you need this time for. If you happen to be on an x86 and you want this for profiling something (ie you don't care about wall clock time, just duration) you can use the rdtsc*() macros. They return number of ticks since the CPU was powered. You can then take a difference of two such values and convert down to meaningful time using do_div() and loops_per_jiffy.

Many thanks, Yes I want th

March 27, 2006 - 2:58am
Anonymous (not verified)

Many thanks,

Yes I want this to profile some functions I write in my module. I will read the functions you point me out. I think I'll use rdtsc*() macros because it is indifferent to show the time elapsed in clock ticks or nanoseconds.

Many thanks!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
speck-geostationary