do_gettiimeofday query
Lal
learner.kernel at gmail.com
Tue Sep 20 07:46:32 EDT 2011
I am having trouble with do_gettimeofday() function. I have following
source code:
int my_module_init(void)
{
struct timeval tv = {0};
do_gettimeofday(&tv);
printk("tv.tv_sec = %lu\n", tv.tv_sec);
return 0;
}
module_init(my_module_init);
This code is built-in kernel, and therefore my_module_init is called
during device_initcall.
However the tv_sec value seems to be wrong (I was expecting this value
to be absolute number of seconds since 1970), but it prints 11 or 12
(which seems to be number of seconds since last boot).
I checked do_gettimeofday function source which gets the value from
xtime variable. I could not find who is responsible for initializing
xtime.
I tried to change module_init by late_initcall_sync. Still it's same.
Any help is appreciated.
Regards
Lal
More information about the Kernelnewbies
mailing list