From owner-freebsd-current Thu May 17 0:22:54 2001 Delivered-To: freebsd-current@freebsd.org Received: from hunkular.glarp.com (hunkular.glarp.com [199.117.25.251]) by hub.freebsd.org (Postfix) with ESMTP id 4133837B422 for ; Thu, 17 May 2001 00:22:52 -0700 (PDT) (envelope-from huntting@hunkular.glarp.com) Received: from hunkular.glarp.com (localhost [127.0.0.1]) by hunkular.glarp.com (8.11.3/8.11.3) with ESMTP id f4H7MmR27336 for ; Thu, 17 May 2001 01:22:48 -0600 (MDT) (envelope-from huntting@hunkular.glarp.com) Message-Id: <200105170722.f4H7MmR27336@hunkular.glarp.com> To: current@FreeBSD.ORG Subject: catching abrupt time changes Date: Thu, 17 May 2001 01:22:48 -0600 From: Brad Huntting Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Suppose I'm a (root) process: I have an appointment in exactly one hour. I call select() and specify a timeout of 3600 seconds, trusting that the system will wake me up just in time. But unbeknownst to me someone sets the clock back 10 minutes while I'm asleep (using settimeofday(), not adjtime()). When select() returns I find that I'm 10 minutes late! My question is: How can I arrange to be notified when someone and makes a corse change to the system clock? One idea I had was to generate a klog message for each call to settimeofday(). This would put the information in syslog, and I could simply add /dev/klog to the list of file descriptors in it's select() call (there will be lots of false alarms, but that's probably not a problem for this application). Another idea was to add a new minor device to klog that just logs calls to settimeofday(). Could this be generalized? Alternately such a device file could be put in /proc (smells like a Linux solution). Or perhaps I could select() for "read" or "err" conditions on /kern/time (from kernfs). Any thoughts? brad P.S. The application in question is a new schedular for cron/at that can sleep between jobs. This would seem to be a good first step toward better laptop power management. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message