Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

accessing xtime variable Linux kernel

I am implementing system call that will return the current time of the day (for learning purpose). I have looked at implementations of gettimeofday() on Linux 3.19.2 from the books I checked I got that The current time of day (the wall time) is defined in kernel/time/timekeeping.c:

struct timespec xtime;

[Linux kernel development Rober Love]

however I couldn't able to get the xtime variable definition in that file.

where is the xtime variable declared in the Linux kernel and how can I access it from my module or my function? what are the headers I should include?

like image 466
m_Et Avatar asked Sep 09 '26 02:09

m_Et


1 Answers

That reference is obsolete. Recent kernels no longer have xtime. Though there are still some fields in the kernel timekeeping structure with a prefix of xtime_ that I assume are descended from it. See, for example, struct timekeeper in include/linux/timekeeper_internal.h.

You would probably want to stick to the slightly more stable functions defined in include/linux/timekeeping.h

like image 77
Gil Hamilton Avatar answered Sep 11 '26 16:09

Gil Hamilton