[comp.os.minix] More on Printer Crashes under 1.5

davep@gapos.bt.co.uk (Dave Parkinson) (11/29/90)

re: The printer problem I highlighted earlier - with my machine always
crashing whenever I attempted to print large files on my DeskJet 500.
I've done some more investigation and herewith the result...

Possible reason:  The timing of the printer and that of the pr_char()
   routine in printer.c are such that the pr_char() routine only manages
   to print a maximum of one character per call - BUSY is being
   dropped just as the function decides to return, and raises a new
   interrupt.  This is then waiting to be serviced as soon as the printer
   interrupt is re-enabled.

Reason I think so: Debugging code revealed the max of 1-char per intrpt in
   the do{}while loop.  Adding a few lines at the start so that the code
   does several reads & tests of the status port before returning on busy
   cured the problem - it gives BUSY time to go away.  (With  this I got
   a maximum o/p of about 94 chars in one go from the loop).
   An alternative cure was hardware based.  My Zenith machine supports
   three operating speeds: SLOW FAST SMART.  Naturally I always run it on
   FAST.  Picking SLOW or SMART cured the problem.  (With SMART the machine
   automatically slows down for I/O operations).

Source Code Fix:  Other than the simple patch mentioned above (which is
   just papering over the cracks) I haven't been able to determine why the
   kernel crashes.  Perhaps someone more familiar with the code can
   pin-point the problem.  As far as I can see the lpr_int() routine doesn't
   re-enable interrupts (for the printer) until the iret of restart().
   One other route would appear to be through the pr_restart() routine that
   is called from the clock interrupt handler.  In this case there is some
   re-entrancy in the kernel code.

   One thing is clear - until the print buffer (16k) is full, the printer
   interrupt routine is being called for each character that is output rather
   than a few times for each block of characters that are output.  ie It is
   hogging the processor and nothing else is likely to get a look in until
   the printer pauses for breath.

   I've tried some code in pr_char() to check for possible stack overflow,
   but this doesn't report any problems.  This may be because the crash
   occurs before the message can be printed!

I'll be glad of any pointers/suggestions.

David Parkinson