Reputation: 43
What I'm currently thinking about is getting the uptime and the current date and time, and then subtracting these. I'll then convert the output to an output that resembles the output of the "date" command in Linux.
But I think that this takes too long? And I think there might be a better solution than this since it looks too brute force.
-- beginner on kernel programming
Upvotes: 0
Views: 674
Reputation: 472
There is a kernel option called PRINTK_TIME
which can turn on a useful feature of adding timestamp before every line of printk.
Upvotes: 1
Reputation: 578
Try the following code
u64 nsec = local_clock();
unsigned long rem_nsec = do_div(nsec, 100000000000);
printk("time from boot is %5lu.%06lu ", (unsigned long)nsec, rem_nsec / 1000);
Upvotes: 0