Subject: Re: Clockticks lost, why ?
To: Nigel Pearson <nigel@ind.tansu.com.au>
From: Bill Studenmund <wrstuden@loki.stanford.edu>
List: port-mac68k
Date: 01/27/1997 15:56:09
> 
> 	Does anyone know it is possible to detect that a video interrupt
> has been missed? If so, it might be possible to automatically correct the
> time by adding a number of ticks to the counter.

This is basically what I've been thinking about doing. The problem is
that the routines which hold off interrupts for a while (mainly SCSI,
but possably also some goofy video stuff and localtalk, when ever
we get it) must be written to check for ticks. If they see one,
the need to accumulate it & clear the chip. Then when they are done, they
need to post the updates.

The thing is that (I think) the 60 Hz clock is used by the scheduler to
switch tasks. We CERTAINLY don't want to do that in mid SCSI-access. If
the current clock code has a hard and soft level (which I think it
does) (there's an interrupt-time part which clears and counts the
interrupt, and a lower-priority-level part which actually switches the
context), then we might be fine. I'm not sure though.

> > Basic problem: we need semaphores to protect
> > critical code rather than shutting off interrupts for hours at a time.
> 
> 	Yes, that is the optimal solution.

semaphores might be the optimal solution to keeping the clock ticks
accurate, but they can't do everything. They could help keep multiple
serial ports going at once (because we can have multiple processies
mucking around with different tty queues rather than just one process
touching one queue). They could also help keep some aspects of
networking going (splsoftnet comes to mind). But the main time
looser, SCSI access, can't be semaphored as I understand semaphoring.
Basically the data stuffing routine needs to be un-interrupted while
sending or receiving. All we can do is go to some sort of polled IO
mode. :-)

Also, the tty and softnet stuff are very much M.I. (machine independant)
code, so we have to be very careful about changing it. I think this
part is ripe for being made to use semaphores, but it must be done
carefully, and to a large bit of code.

I think it'd be great, and probably needs to eventually be done. But it's
not a quick fix.

Thoughts?

Take care,

Bill