Timekeeping [Was: Re: cvs commit: src/usr.bin/vmstat vmstat.c src/usr.bin/w w.c]

Bruce Evans bde at zeta.org.au
Sat Oct 22 02:28:03 PDT 2005


On Fri, 21 Oct 2005, Andre Oppermann wrote:

> Poul-Henning Kamp wrote:
>> Again, if you have been sitting in DDB, what exactly is the definition
>> of "uptime" ?
>
> IMO it's this:
>
> Uptime is the time the operating was available to present it's common
> services to userland.  That excludes any suspend and ddb times.  Single
> user mode however counts because the OS was servicing userland even if
> there was only one user.  Uptime is represented in SI seconds.

I agree for suspend and ddb, but not for single user mode.  The system
can be shut down to single user mode and restarted without rebooting.
Restarting runs /etc/rc etc.  The system can hardly be considered to
be up until /etc/rc has completed, but we've never bother breaking
boottime of providing a beginning-of-uptime variable to give the
actual start of uptime.  SIngle user mode is even more clearly down
for remote services, but ruptime doesn't understand this.  I don't
really understand the protocol, but ruptime seems to just talk to
rwhod; rwhod never understood the difference between local and remote
uptime and just uses the kernel boottime like w used to.

> Time since boottime is the UTC delta from the time of when the OS
> initialized itself to now.  Leap seconds cause deviations from uptime.
> Time since boottime is represented as numerical delta in seconds from
> two UTC timestamps.

What's a UTC delta?  Deltas don't (shouldn't) depend on the calendar.
Leap seconds shouldn't cause deviations.  They don't now, since
boottime is broken (set backwards) to compensate for them.  What are
numerical deltas and UTC timestamps?  In C99, there are only time_t's
in some scale and difftime() to not-necessarily-numerically subtract
them.  In POSIX, using difftime() is essential sonce the broken scale
breaks mainly numerical differences.

> Uptime != Time since boottime.

Only because the correct base point is not the boot time.  We still use
boottime for the base, so CLOCK_MONOTONIC only gives a different value
due to bugs.

Bruce


More information about the cvs-src mailing list