Subject: Re: w cmd on energy saving machines: problem and proposed solution
To: Ignatios Souvatzis <is@netbsd.org>
From: Robert Elz <kre@munnari.OZ.AU>
List: tech-userlevel
Date: 06/19/2001 02:29:02
    Date:        Fri, 15 Jun 2001 22:28:52 +0200
    From:        Ignatios Souvatzis <is@netbsd.org>
    Message-ID:  <20010615222852.A23683@beverly.kleinbus.org>

Um ...

  | However, at the time the internally used idle time is used in any way, 
  | the sleep time of the process is already known to w. Therefore, I propose 
  | to use that instead:

The "idle time" is supposed to be how long the human has been idle, not
how long processes run by the human on the terminal have been idle.
That is, it gives you a clue whether the person is sitting there at
their (virtual) terminal or not, and if not, how long go since they were.
(If they've been active in the past 30 seconds, write/talk often works,
if they've been active in the past 10 minutes the (old style) telephone
often works, beyond that, use email...)

In general the only way to tell whether the human is idle or not
is to notice whether they're interacting with some process or other, and
at least currently, the only way to do that is to look at the access time
on the terminal (which isn't actually very accurate - as it is updated
whenever a process starts a read on the terminal, not when the read is
actually satisfied by the user).

Clearly for /dev filesystems mounted noatime this scheme breaks completely.

If there is to be a fix for this, the correct one would be to have the
tty layer remember how long since it last received actual input, and then
make that available to the processes that care ('w' 'finger' etc).
How to achieve the latter part I have no idea of at the minute (certainly
not opening the tty and doing an ioctl - perhaps this could be some kind of
sysctl?)   Recording the time when input arrives is simple though.

Certainly looking at the idle time of a process running on the terminal
isn't the way to fix the problem.

But ...

  | Appendix: finger (actually fingerd) shows the same problem, because the
  | same definition of idle time is used. Best we can do here is to clip the
  | idle time to the login time. (Else we'd have to make it a kmem groveler, too.)

certainly clipping the idle time to the login time is entirely reasonable,
imagining a method for the user to be idle while they were actually connecting
is a little difficult.

Better perhaps would be to note that where the computer idle time (from atime)
is longer than the login time, then clearly the computation has failed, and
rather than clipping it, simply report that it is unknown ("??" in idle field).

That is, assuming a better method of truly discovering what the idle time
is isn't created first.

kre