home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1742 / README < prev    next >
Encoding:
Text File  |  1990-12-28  |  4.6 KB  |  83 lines

  1.     A FAST PARALLEL PORT DRIVER THAT DOES NOT USE INTERRUPTS
  2.  
  3. This is the source of a parallel port driver for System V/386, rel. 3.2.
  4.  
  5. It is different from the standard lp(7) driver because it does only raw
  6. output (while lp(7) uses the termio(4) line discipline), and it does not use
  7. interrupts. It assumes that the printer has an internal buffer, so that the
  8. most efficient style of communication is to pump characters as fast as
  9. possible until the buffer fills, then sleep for a relatively long period
  10. when it signals not ready, and try again thereafter.
  11.  
  12. This implies that no interrupt processing is done, which has the advantages
  13. of simplicity and low overhead, and, perhaps most importantly, of not using
  14. one of the scarce interurpt lines of the ISA bus.
  15.  
  16.     OUTLINE OF DESIGN
  17.  
  18. Output is done entirely in the top half of the driver, and therefore not
  19. inside a critical region. This could mean that on a very busy system the
  20. pumping could be interrupted by task switching. This, if important, can be
  21. easily obviated, by turning the pumping loop into a critical region; if this
  22. is done it becomes important to limit the number of characters pumped in one
  23. go, by having two loops, the outer one that runs until busy is signaled, the
  24. inner one for a fixed number of characters, and put only the inner one in
  25. the critical region.
  26.  
  27. A similar driver has been posted by Mike Grenier; this version is completely
  28. rewritten and uses different logic. In particular the polling waits are
  29. either very short if busy or interruptible if sleeping.
  30.  
  31.     INSTALLATION
  32.  
  33. As it stands it is especially designed for a stock System V/386 rel. 3.2
  34. system, e.g. ESIX, especially inasmuch installation is concerned. It should
  35. be sufficient to say 'make install' to install it, and then you should say
  36. 'idconfig' and 'idmkunix' to rebuild the kernel (but first finish reading
  37. this file). The Makefile will install "pp.h" into "/usr/include/sys", which
  38. is required.
  39.  
  40. This driver is so simple that it should port very quickly to other flavours
  41. of Unix; the only thing that may not be portable is the reference to a kernel
  42. procedure called 'tenmicrosec()' in pp.c, which does a busy loop of 10
  43. microseconds.  It is fairly easy to roll your own, of course.
  44.  
  45.     CONFIGURATION OF PARAMETERS
  46.  
  47. This version can be configured in several ways. You can, in file "pp.h",
  48. define ppSTATICSZ as either zero, in which case a buffer will be stolen from
  49. the block cache whenever a parallel port is open, or non zero, in which case
  50. a static buffer will be allocated for each parallel port. The only reason
  51. for a buffer in this driver is to cut down on procedure invocations to fetch
  52. characters to transmit from the user space, so even a small buffer will be
  53. sufficient to amortize the cost of a procedure call (anything upwards of 64
  54. bytes is probably OK). I recommend using a smallish static buffer (say
  55. 128-256 bytes), as probably the code that implements cache block stealing
  56. and restitution is about that size anyhow :-), even if static allocation is
  57. aesthetically less pleasing (character by character fetching was simpler and
  58. insignificantly slower, but I will not bother putting it back in). Note that
  59. there is no interlocking provided for access (as opposed to allocation) to
  60. the buffer; if two processes try to write to the printer at the same time,
  61. they will use the same buffer without any synchronization. It is expected
  62. that higher level synchronization and queueing mechanisms exist.
  63.  
  64. You can configure, in file "space.c", a number of things; first the
  65. addresses of the IO ports of the printers you have got. These should not
  66. need changing at all on an AT compatible 386. At worst, you can
  67. comment/uncomment those lines that correspond to devices you have/don't
  68. have. You can also configure the masks and the durations for long term
  69. (waiting for the printer to be online) pauses and for short term (waiting
  70. for the interface buffer to become less choked) pauses. You can also
  71. configure the number of tens of microseconds we are prepared to busy wait
  72. for the interface to accept the next character before switching to short
  73. term pausing and waiting for it to reach some low water mark.
  74.  
  75. In general the mask and pause values given as defaults should work, and the
  76. pause durations do not matter that much; the max spinning count (busy wait
  77. loops) parameters is more critical, in that if it is too small the printer
  78. will be driven very slowly (only a few characters per second), because a
  79. short pause will be entered on every character. If it is too large some time
  80. will be wasted when the interface becomes choked before we give up spinning,
  81. but this is probably not very frequent or important.  The default value is
  82. conservative enough for my printer, but raise it if you are in doubt.
  83.