Updated: 2022/Sep/29

Please read Privacy Policy. It's for your privacy.


TIME_SECOND(9)             Kernel Developer's Manual            TIME_SECOND(9)

NAME
     time_second, time_uptime, time_uptime32 - system time variables

SYNOPSIS
     #include <sys/time.h>

     extern const time_t time_second;
     extern const time_t time_uptime;
     extern const uint32_t time_uptime32;

DESCRIPTION
     The time_second variable is the system's "wall clock", giving the number
     of seconds since midnight (0 hour), January 1, 1970, (proleptic) UTC,
     minus the number of leap seconds.  It is set at boot by inittodr(9), and
     is updated periodically via timecounter(9) framework, and also updated by
     the settimeofday(2) system call.

     The time_uptime variable is a monotonically increasing system clock.  It
     is set at boot, and is updated periodically.  (It is not updated by
     settimeofday(2).)

     The time_uptime32 variable is the low-order 32 bits of time_uptime, which
     is cheaper to read on 32-bit platforms.

     You must only read the variables time_second, time_uptime, and
     time_uptime32; you may not write to them or take their addresses.  They
     may be implemented as macros.

     The bintime(9), getbintime(9), microtime(9), getmicrotime(9),
     nanotime(9), and getnanotime(9) functions can be used to get the current
     time more accurately and in an atomic manner.

     Similarly, the binuptime(9), getbinuptime(9), microuptime(9),
     getmicrouptime(9), nanouptime(9), and getnanouptime(9) functions can be
     used to get the time elapsed since boot more accurately and in an atomic
     manner.

SEE ALSO
     clock_settime(2), ntp_adjtime(2), timespec(3), hardclock(9), hz(9)

NetBSD 10.99                     July 16, 2023                    NetBSD 10.99