Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Sep 2005 18:45:52 +0200
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Jung-uk Kim <jkim@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/kern vfs_subr.c 
Message-ID:  <11401.1126543552@phk.freebsd.dk>
In-Reply-To: Your message of "Mon, 12 Sep 2005 12:40:49 EDT." <200509121240.51775.jkim@FreeBSD.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200509121240.51775.jkim@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@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?11401.1126543552>