super-HZ timers on SysV/386?

Andy Pfiffer apfiffer at admin.ogi.edu
Fri Jun 1 18:02:54 AEST 1990


Problem:
I have a dumb A/D converter plugged into a System V/386 system that requires
some clever device-driver wizardry. (I love a challenge)

It has no on-board interrupt or DMA capability.  I need to sample it,
within +/- 10%, at constant, super-HZ (ie: higher than clock tick) intervals;
8000 Hz would be ideal.

Yes, this implies significant computrons may be required to accomplish this,
but hey -- I didn't design the dang thing.  It is not expected that samples
will be taken for extended periods of time.  In fact, it may only need
samples for 10 seconds or so, often less.  It is acceptable to "degrade
system throughput" to accomplish the task.

Obvious options:

a) Write a tightly controlled software timing loop that runs at or near splhi()
   and pull in my samples, burning CPU cycles by the truckload.

   The drawback is that this driver may run on a variety of 386SX/386DX/486
   systems of widely varying clock speeds, caches, etc.  It doesn't thrill
   me to think of all the subtle tuning that might be needed...

b) Say uncle and quit.

Not-So-Obvious:

Theoretically, before I start sampling, I could reprogram one of the 8253-ish
interval timers with my desired frequency, swap out the existing clock interrupt
vector with my own, calling it when appropriate so that the system has *some*
chance of echoing characters.  The advantage is that I get a reliable,
albeit often, interrupt across all platforms.

The disadvantage is that I am playing with the pulse of the system...and
I've haven't yet seen "Flatliners*" to learn all of the tricks. :^)
It might be far too easy to get something very, very wrong.

Yes, I am aware of the fact that one can write a driver routine that is
called at every clock tick, but 100 Hz isn't the same as 8000 Hz.

Is there a less obtuse, sanctioned way of using one of those timers to my
benefit?

Any ideas, comments, or perhaps even insults will be appreciated.

Quizzed,
Andy Pfiffer
--
*Yet another obscure reference.



More information about the Comp.unix.i386 mailing list