I am new to kernel programing and am trying to find a way to get a timestamp into some kernel code we had custom written for us.
it looks like the normal c library time.h has a get_clocktime() function, but this does not exists in the linux/time.h lib.
Is there a way to stamp my debug/info meassges from my kernel code with a time at millisecond resolution. The timestamp on the log file is buffered and thefore off.
Thanks
Hi
I am no Kernel Programmer;), however I guess what u are looking for
is: gettimeofday()
e.g.
#include <sys/time.h>
#include <stdio.h>
void main()
{
struct timeval tv;
gettimeofday(&tv, NULL);
unsigned long long millisecondsSinceEpoch =
(unsigned long long)(tv.tv_sec) * 1000 +
(unsigned long long)(tv.tv_usec) / 1000;
printf("ms since 1/1/1970: %llu\n", millisecondsSinceEpoch);
}
Hint: if you are searching for ANSI c hints in google, add ansi or cpp
or POSIX to your question, e.g.:
"gcc unix timestamp milliseconds"
HTH