device driver subtleties, etc.

speck at CIT-VAX.ARPA speck at CIT-VAX.ARPA
Thu Aug 9 15:34:25 AEST 1984


From:  Don Speck <speck at CIT-VAX.ARPA>

    In my backlog of mail, I've gotten no less than 6 (!) useful replies
to my question about sleep() at ipl 0x14, and 3 to my question on return
values from close().  My thanks to the following wizards:

	Bob English, Larry Allen, Andrew Klossner, Erik Fair,
	David Butterfield, Mike O'Dell, Jim Balter, Tim Smith.

My questions came about from doing a complete rewrite of lp.c to turn it
into an efficient raw Trilog/Printronix/LP11 printer/plotter driver.  We
have two Trilog Colorplot raster plotters that plot 5500 bytes/second, a
bit more than 4.2bsd lp.c on a VAX/780 can supply.  The driver would sit
in a loop in the interrupt routine, feeding characters to the printer --
and the printer was always ready for more, so an interrupt lasted for as
long as there were characters in the buffer (say 0.2 seconds).	Response
time?  What response?  We were lucky if our typeahead echoed.

    Since we have two such printers, we needed more than a factor of two
speedup.  I threw out lp.c and wrote a raw driver with none of the fancy
buffering of getc() / putc(); the transmit loop is 40 times faster.  The
first time I tried it I got 5300 interrupts per second (amazingly enough
this was better than before!).	Giving it an extra 5us per character for
printer handshaking got rid of the massive interrupts, so now I can plot
graphics with only 10% system time, versus 100% system time with lp.c.

    I also took Mike O'Dell's sage advice and don't bother to detect any
errors that I don't have to.  It just waits for the printer to come back
online.  This is effectively what lp.c did anyway.

    After beating on it a while longer, I'd be happy to post my two-page
driver to net.sources if somebody would just tell me how to do it!

					Don Speck



More information about the Comp.unix.wizards mailing list