[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Q] how to deal with 'clock vs hwclock' call



On Sun, May 31, 1998 at 02:27:58PM -0400, Gregory S. Stark wrote:

> Dirk Eddelbuettel <edd@debian.org> writes:
> 
> > I had a bug reported against apmd because apmd.c somewhat hackishly calls
> > clock(8) as per
> >
> >          case APM_CRITICAL_RESUME:
> >             time( &then );
> >             system( "clock -s" );
> >             time( &now );
> >             check_power( 1, 0 );
> >             break;
> 
> Odd, I don't seem to have a clock(8) or a /usr/s?bin/clock.

There was one.  It went away in favour of hwclock, unfortunately.  I don't
mind the name change, but hwclock's user interface is none too great.

> And I don't quite see why this call has to be there. The kernel already
> does what I think you're trying to do:

Unfortunately, it doesn't do it properly.  I haven't had time to look at it
closely, but my laptop loses _large_ amounts of time when it goes into
suspend.

One interesting effect is due to time zones:  last time I looked, the kernel
records the GMT offset the first time you go into suspend/standby, and uses
it forever after.  Interesting side effects:

	boot (GMT-0500, Eastern standard time)
	suspend
	resume
	Ontario changes to daylight savings time, GMT-0400
	(clock is adjusted automatically by kernel, which keeps everything
	  in GMT)
	suspend
	resume
	Clock has been set to GMT-0500.
	
Now, I can't remember which clock ends up wrong, but the output of 'date'
certainly doesn't match.

In any case, the kernel's clock resetting works really badly even if that
kind of obscure situation doesn't happen.  I really don't know why it does
such a rotten job.

Oh, while I'm on this topic, once upon a time I added a feature to apmd that
causes it to run arbitrary programs on suspend/standby/resume, and the apmd
author agreed to add them to the next apm package release... about two years
ago.  There hasn't been a new release since!  If anyone wants my patch, I
can dig it up.

Here's a sample of apmd --help with my patch:

	usage: apmd [-VvW] [-p percent-change] [-w warn-percent]
	        [-s on-suspend] [-S on-standby]
                [-r on-resume-suspend] [-R on-resume-standby]

I use this to run 'hdparm' to (re-)enable hard drive spindown when I come
out of suspend.  We could also use it to run the right 'hwclock' program
from a script.

Have fun,

Avery


--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: