Subject: Re: A3000 system clock
To: None <amiga@NetBSD.ORG>
From: Ty Sarna <tsarna@endicor.com>
List: amiga
Date: 12/10/1995 20:55:06
In article <199512100846.CAA28410@melanoma.uchicago.edu>,
D. Champion <d-champion@uchicago.edu> wrote:
> I don't intend to get into any fights here, but I think what Steve was
> saying -- based on the rest of his content -- is that there's a battery-
> based clock and a "system clock" maintained by the OS, and that they can
> be out of sync with one another.  The OS only expects its own clock to
> contain correct localtime; the battery clock can be set to anything you
> wish without impacting the system at all, unless you have weird software
> which insists on using the battery resource.

"The system" includes at least two pieces of "wierd software" that use
the battery resource, and I sometimes use another one (an NTP-like
system for AmigaOS).

Saying software is wierd because it uses the resource is like saying
"ps" on netbsd is wierd because it uses libkvm. It may not be a commonly
used feature, but it is a defined system interface.

> >Fine if I you always boot from partitions on which you've modified your
> >user-startup. This can't be guaranteed.
> 
> Defensive, aren't we?

No, practical. I do this often. I'm sure many others do as well.

> Sounds good to me, although I've missed any implementational details
> you've given as I usually skip over this list.  (Just caught me at a
> time when I don't have procmail installed....)  Please show, if you
> haven't, just because I'm curious.  If you have described it already,
> I'll find it.

Basically, have a kernel variable that contains the number of seconds
offset of the RC from gmt. Default at boot time is zero. Have all
ports add this value to the time when writing to the battery clock, and
subtract afyter reading.

Provide a way to get and set this kernel variable (I did it as a device
driver back pre-1.0, the correct MI method now would be a sysctl).

So far, by default the system behaves *identically* to how it currently
does. It would only behave differently if the variable is set non-zero
by a userspace program (eg placed by the user (not by default) in
/etc/rc).

The userspace program is pretty simple, along the lines of:

	do {
		get offset
		compute local and gmt time
		caclulate new offset (differentce between above)
		set offset
	} while (offset != old offset)

The while is needed in case the first change moves us over a DST change,
in which case the offset needs to be recomputed.