Subject: Re: PRAM & the Time Manager
To: Charles J. Williams <chas@volt.nrl.navy.mil>
From: Allen Briggs <briggs@puma.bevd.blacksburg.va.us>
List: port-mac68k
Date: 03/11/1996 08:46:41
> If I understand the problem correctly, One of the VIA interrupts is
> responsible for updating this time variable.  The interrupt runs at
> the lowest priority, and attempts to run at HZ times per seconds.  So
> its slightly more accurate than the RTC.
> 
> Various drivers (mostly the scsi disk driver i believe) disables interrupts
> and then calls delay() for various reasons.  This causes the clock to loose
> time.

This is close.  One of the VIA1 interrupts is being used for timing.  The
m86k interrupt structure is such that you have 7 interrupt priority
levels honored in the hardware.  Higher levels mask interrupts from the
same and lower levels.  So if you're running at level 2 due to a level 2
interrupt, you will not receive other level 2 or any level 1 interrupts,
but you might receive level 3-7 interrupts.  On the mac, level 1
interrupts are from VIA1, level 2 from VIA2/RBV, level 4 from the SCC,
and level 7 from the debugger (NMI) switch.  The SCSI and ethernet
(NuBus) interrupts are on VIA2.  Most everything else is on VIA1.  If
any interrupt handler is running, it's masked off the clock interrupts.

Now, it might be a good idea to keep track of the RTC and slew the
NetBSD clock.  I haven't come up with a good algorithm for that, yet,
though (I haven't really looked at it, either).  If we can keep the
NetBSD clock (mostly) up-to-date, then we can enable writing to the
PRAM again.  When the NTP updates happen, they'll update the RTC,
too, and everyone will be happy.

If y'all want to look at that, please do.  Quite a few people would like
to see it...  Myself included.

> Does any of this make sense?

Yes.  One option you didn't mention is to do a sort of software masking
of interrupts and basically put all interrupts on the same priority
level.  I don't think that that's a viable option--especially if the
SCC is to keep up at all, but it's another option.

-- 
  Allen Briggs - end killing - briggs@bev.net ** MacBSD == NetBSD/mac68k **
   Where does all my time go?  <a href="http://www.netbsd.org/">Guess.</a>