do_gettiimeofday query

Lal learner.kernel at
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};
    printk("tv.tv_sec = %lu\n", tv.tv_sec);
    return 0;

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

I tried to change module_init by late_initcall_sync. Still it's same.

Any help is appreciated.


More information about the Kernelnewbies mailing list