cvs commit: src/sys/kern vfs_subr.c

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Sep 12 09:45:58 PDT 2005


In message <200509121240.51775.jkim at FreeBSD.org>, Jung-uk Kim writes:

>Please make sure to use `time_uptime' if you need monotonic timestamp.  
>Especially many network stacks seem to make sequence IDs and 
>timestamps to expire from `time_second' instead of time_uptime.  
>time_second is not guaranteed to be monotonic!  time_uptime is.
>
>http://docs.freebsd.org/cgi/mid.cgi?8153.1126340565
>http://docs.freebsd.org/cgi/mid.cgi?20050909214808.GA6021

I would like to add that this is *also* true for userland
where uptime is called clock_gettime(CLOCK_MONOTONIC,...).

Please consider carefully, if you need a timestamp for a certain
time of day or just a certain inverval of time measured from now.

In the latter case, it is _always_ uptime/CLOCK_MONOTONIC you want.

Failure to do this means that your program/kernel code will do the
wrong thing when the clock is stepped (manually or by NTP).

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the cvs-src mailing list