kernel function to get the system time

kernel function to get the system time

Post by Casper H.S. Dik - Network Security Engine » Thu, 16 Jul 1998 04:00:00


>Hi,  I am looking for a kernel level function to get the current system time.
>I tried both clock_gettime() and time(2). But, both of these do not seem to
>work in my STREAMS module. In the first case, the module started behaving
>weirdly after the call to clock_gettime()[ioctl failed etc], in the second
>case the machine rebooted, when the call to time(2) happened.  I assume that
>this means that these functions are not available at the kernel level. I will
>be a lot helped, if anybody can point me in the right direction.

No, these certainly dont' work at the kernel level.

Try ddi_get_time() or ddi_get_lbolt()

(Only stuff in section 9 can be used inside kenrel modules)

Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.


1. Getting system time in kernel..

        As an example, a filesystem might internally store local times in its
inodes. You may not be free to change the on-disk format.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at
Please read the FAQ at

2. Can't compile Multimedia 2.1 on my machine...

3. getting system date/time from another system

4. Why should I use Linux?

5. functions that return the system time in Solaris2.6

6. Virus programs

7. GPL issuefor run time kernel function overwrite

8. VPN w/FreeBSD & Win2K

9. Any kernel function can get the time?

10. Daylight Savings time, system time, hardware time....

11. DDI/DKI kernel functions for current time

12. Getting system time inside a device driver? (Interactive)

13. getting last time user accesssed the system?