Subject: Re: uptime(1) behaviour & sleep mode
To: Arnaud Lacombe <>
From: Daniel Carosone <>
List: tech-userlevel
Date: 07/13/2006 11:52:52
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Jul 12, 2006 at 11:50:46PM +0200, Arnaud Lacombe wrote:
> With recent change in ACPI and in time handling, I was wondering what
> should be the behaviour of uptime(1) when we start to deal with sleep (wi=
> S3 or APM). uptime(1) defines it as "the length of time the system has
> been up" but when the laptop goes into sleep mode, is it still considered=
> being up or not ?

It's a good question. Historically, such as with apm sleep, the answer
has been "yes".  That's at least in part coincidence, because what
uptime(1) shows is pretty much the result of taking the difference
between the current time and the time when the system was booted.

Sleeps are just one aspect of the question, clock resets via date(1)
and ntpd(8) also play a part.  This is especially important if the
wall clock is wrong at boot time.

There hasn't been a clear distinction in either representation or
usage between times that correlate with the wall clock, and times that
correlate with 'runtime' in the sense of processing even when clock
corrections are applied.  This is true and needs to be cleaned up in
the kernel, where some kinds of events should belong to one or the
other "time space", and also in userland.

With the merge of timecounters comes the start of an effort in the
kernel to make this separation clearer, and one result of this is that
we now have the ability to actually offer a choice of what to show
here.  We now keep track of the wallclock time we knew when the system
was booted, the current wallclock time, and the interval we've
actually seen elapse in between separately.  They don't have to be in
agreement, so its up to you to decide which is appropriate for your

Even here, though, I think time spent in sleep is treated as 'up' for
both kinds of clock; we don't track time spent actually ticking
separately, though perhaps we could if there's something that would be
interested in this value. Maybe that's "only" curious users?


Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.4.4 (NetBSD)