Topic: problem programming for i/o device


Author: rsand@remus.rutgers.edu (Richard Sand)
Date: 8 Feb 94 01:09:20 GMT
Raw View
Ok, here's an interesting programming problem.

First the situation: I have a 486-dx pc with an IDE hard drive.  I built an
interface card for it that has a digital-audio receiver on it.  This
receiver takes data and places it into a 4096-word fifo.  On the other side,
the pc reads the fifo (16-bit I/O transfer).  The data rate is 88,200 words
per second.

Now, the pc can easily handle the data rate.  I set a test program to
continually read an i/o port.  It first does an 8-bit read (get board
status) and then does a 16-bit read (get next data sample).  After filling
a 1024 word buffer (or 256 or 512, doesn't really matter), the program
writes the buffer to disk, using the Borland C++ file-handling routines.
The program does this 1000 times to test the average throughput, which is
about 3.5 times the receiver's data rate.

Now the problem:  The worst-case scenario for a single write operation was a
whopping 54 milliseconds.  Why, I'm not sure.  But it is easy to see by the
above numbers that the fifo will fill in just under 47 milliseconds.

Now the solution: Make the pc continue to read from the fifo while the drive
is seeking.  Obviously, the drive's raw data-rate can easily handle the
receiver.  I can write blocks of 1-sector length, eliminating any need for
the drive to perform a seek in mid-write.  This way I can program the thing
to seek, go back to doing more reads until the last seek was completed, then
write the entire last buffer, then go back to reading more into the current
buffer, without having to worry about my current buffer filling before the
last buffer completed writing.

Now the question: How do I do all of this???

I am fluent with Borland C++ and assembly language.  It sounds to me like
this would be a great parallel processing application.  Shame i'm using a
pc.

Any help greatly appreciated!  Please E-mail responses.  Thanks.


--
Richard Sand
Rsand@Remus.Rutgers.Edu