home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os2 / misc / 29238 < prev    next >
Encoding:
Text File  |  1992-09-03  |  16.2 KB  |  336 lines

  1. Newsgroups: comp.os.os2.misc
  2. Path: sparky!uunet!gatech!news.ans.net!ans.net!db3l
  3. From: db3l@ans.net (David Bolen)
  4. Subject: COM performance hints with 16550
  5. Sender: news@ans.net (News Administrator)
  6. Message-ID: <1992Sep04.001724.16103@ans.net>
  7. Date: Thu, 3 Sep 1992 20:18:53 GMT
  8. Organization: Advanced Network & Services, Inc. - Elmsford, NY
  9. Lines: 325
  10.  
  11. Warning: This is pretty long, but there's a summary at the end.  If you just
  12.          want to see a brief statement now:
  13.  
  14.      If you have a 16550, have a serial device that keeps DSR high while
  15.      it is on (I think most modems do this by default, or are configurable),
  16.      doesn't do hardware flow control, or doesn't mind getting up to 15
  17.      characters after dropping CTS and/or DSR, make sure you set BUFFER=ON
  18.      when configuring your COM port with the MODE command.  With default
  19.      settings, BUFFER=AUTO is really no different than BUFFER=DISABLED.
  20.  
  21.      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  22.  
  23. I recently obtained a copy of the OS/2 physical device driver reference and
  24. was reading through the information about the async drivers (COM/VCOM.SYS).
  25.  
  26. From the number of posts on the subject (some from myself), it seems that a
  27. number of people are confused about what the various MODE COM settings mean,
  28. and what sort of setup was the most efficient use of COM ports when a 16550
  29. UART was present (which seems to be universally regarded as a good idea to
  30. have in order to gain good performance).  I normally use OS/2 COM programs
  31. with the RTS=HS,BUFFER=AUTO settings (as is normally recommended on the net
  32. and in the FAQ) and wondered if I was fully exploiting the capabilities of my
  33. 16550.  In addition, I was still having problems with DOS environment programs
  34. (notably kermit 3.11 that just dies a horrible death) and hoped to learn a bit
  35. about how that might be improved.
  36.  
  37. After reading a bit, and performing some experimentation, I've come up with
  38. the following information and conclusions that may help other people with the
  39. 16550s.  I don't place any guarantees on this information, other than that it
  40. is accurate to the best of my knowledge and seems to be backed up by my
  41. experimental results.  I hope it proves helpful, or at least helps to explain
  42. the relationship between some of the MODE parameters and the use of the FIFO
  43. buffers provided by the 16550.
  44.  
  45. (in the following, when I use the term 16550, the OS/2 drivers actually
  46.  require an NS-16550A or compatible chip, and I believe the current level
  47.  chips as discussed previously in the OS/2 groups are 16550AFN or 16550AF)
  48.  
  49.      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  50.  
  51. Introduction:
  52. ------------
  53.  
  54. The 16550 provides for a 16-character receive hardware buffer that can be set
  55. to generate an interrupt every 1, 4, 8 or 14 characters.  It can also hold up
  56. to 16 characters in a transmit buffer, generating an interrupt only when that
  57. buffer is empty.  In other words, in its most efficient mode, the 16550 can
  58. handle transmission and receipt of data in roughly 16-byte chunks, only
  59. interrupting the CPU at the end of each chunk.
  60.  
  61. Note that even if you don't make use of the extended buffering from the
  62. point of view of interrupt handling, but still receive an interrupt for
  63. every character received or transmitted, the 16550 buffer can be helpful,
  64. as it can buffer received characters if the COM handler misses an interrupt,
  65. thereby preventing receive overruns.
  66.  
  67. The OS/2 COM driver can fully exploit these capabilities of the 16550
  68. depending on how it is configured.  Here's the rub though - if you take the
  69. default COM settings, and even if you use MODE to set the BUFFER parameter to
  70. AUTO, the COM driver is only partially using the capabilities of the UART.
  71. In other words, the settings that are normally posted to these groups, and
  72. are in the FAQ are not the most efficient settings.  In fact, from what I
  73. can tell, a BUFFER value of AUTO is no better than DISABLED with the other
  74. defaults for the modem signaling values.
  75.  
  76.  
  77. COM Driver Settings (MODE):
  78. --------------------------
  79.  
  80. The extended hardware buffering mode of the async driver can be controlled via
  81. the BUFFER parameter of the MODE command.  It can take on three values:
  82.  
  83.      ON        Set transmit/receive triggers to fully exploit buffering.
  84.             (16-character transmit/receive queues for 16550).
  85.      OFF    Set transmit/receive triggers to a single character.
  86.      AUTO    "Automatic Protocol Override".  Adjust the transmit/receive
  87.          triggers according to handshaking protocols in effect.
  88.  
  89. The "handshaking protocols" for AUTO mode use the following signals:
  90.  
  91.     RTS = Request To Send        ( Signals FROM OS/2 COM Driver )
  92.     DTR = Data Terminal Ready
  93.     CTS = Clear To Send        ( Signals TO OS/2 COM Driver )
  94.     DCD = Data Carrier Detect
  95.     DSR = Data Set Ready
  96.  
  97. and refer to the following:
  98.  
  99.    * Input Sensitivity using DSR
  100.     - MODE option IDSR, default ON
  101.     - If this setting is ON, then the driver will only accept data from
  102.       the device while the DSR line is active.
  103.    * Output Handshaking using CTS, DSR, DCD
  104.     - MODE options OCTS, ODSR, default is both ON
  105.     - No MODE option for DCD - MODE always sets it OFF
  106.     - This setting controls whether CTS, DSR or DCD are used to control
  107.       the flow of data to the modem.  If any of these settings are ON,
  108.       the driver stops giving data to the transmit hardware as soon as
  109.       the corresponding control signal drops.
  110.    * RTS Control Mode
  111.     - MODE option RTS, default is ON.  Can be one of the following:
  112.         + Enabled                           [MODE=ON]
  113.         + Disabled                               [MODE=OFF]
  114.         + Input Handshaking (RTS drops on input queue full)    [MODE=HS]
  115.         + Toggling on Transmit (RTS drops unless transmitting) [MODE=TOG]
  116.     - This setting controls how the RTS signal is controlled by the
  117.       driver.  If ON, DTR is used to signal when the COM port is
  118.       active, while if HS, DTR is used to control the flow of data
  119.       from the modem.
  120.    * DTR Control Mode
  121.     - MODE option DTR, default is ON.  Can be one of the following:
  122.         + Enabled                           [MODE=ON]
  123.         + Disabled                               [MODE=OFF]
  124.         + Input Handshaking (DTR drops on input queue full)    [MODE=HS]
  125.     - This setting controls how the DTR signal is used to control
  126.       the flow of data.
  127.     - This setting controls how the RTS signal is controlled by the
  128.       driver.  If ON, DTR is used to signal when the COM port is
  129.       active, while if HS, DTR is used to control the flow of data
  130.       from the modem.
  131.  
  132. A typical default configuration for the COM port is (ignoring some of the
  133. MODE parameters not relevant to this post):
  134.  
  135.     IDSR = ON        ODSR   = ON
  136.     OCTS = ON        DTR    = ON
  137.     RTS  = ON        BUFFER = AUTO
  138.  
  139. And most suggestions for configuring the COM port for better control
  140. explicitly set RTS=HS, and BUFFER=AUTO, so I expect that many people are
  141. running with the above settings, except with RTS=HS, allowing full hardware
  142. flow control (RTS/CTS) to the modem.
  143.  
  144.  
  145. Setting Interaction:
  146. -------------------
  147.  
  148. For the purposes of this post (getting the most performance out of the 16550),
  149. the only settings that are really important from the above discussion are the
  150. "Extended Hardware Buffering" (BUFFER), "Input Sensitivity using DSR" (IDSR),
  151. and "Output Handshaking using CTS, DSR, DCD" (OCTS,ODSR).
  152.  
  153. Here's the basic problem.  In order to accomplish the latter two settings in
  154. their default modes, the AUTO buffering mode basically stops using the FIFO
  155. buffers.  In particular, the following adjustments are "automatically" made:
  156.  
  157.    * If IDSR is enabled, then the COM driver is set up to respond
  158.      to a lowering of the DSR signal within one character time.  To ensure
  159.      this, the driver adjusts the receive trigger to be a single character.
  160.      In other words, it lets the 16550 generate an interrupt per character.
  161.      The full 16-character receive buffer is still available to prevent
  162.      receive overruns, and the transmit trigger is not adjusted.
  163.    * If either OCTS, ODSR (or ODCD - only changeable from a program) are
  164.      enabled, then the device driver will respond to a lowering of the
  165.      appropriate signal within a single character time.  To do this, the
  166.      transmit trigger is lowered to a single character - the 16550 is set
  167.      to generate a transmit interrupt for each character, although the
  168.      receive trigger is not adjusted.
  169.  
  170. The reason both of these automatic adjustments are made is to take the safe
  171. course, and assume that anything using those signals has been designed to
  172. assume that the signals take action within a single character time.  For
  173. example, without fixing the transmit trigger, the modem could lower the
  174. CTS signal, but the 16550 might continue transmitting up to 15 characters
  175. that might still be in the FIFO transmit queue.
  176.  
  177. Of course, the problem is that with the default settings, both of these
  178. rules come into effect, and the driver ends up getting an interrupt per
  179. character for both transmitting and receiving characters.  In other words,
  180. you end up using the 16550 just like any lower UART, with the single advantage
  181. that the receive FIFO buffer on the chip helps avoid receive overruns.
  182.  
  183.  
  184. Improving Settings
  185. ------------------
  186.  
  187. In order to make more effective use of the 16550, you can do one of three
  188. things:
  189.  
  190.    * Explicitly set the extended buffering on (MODE BUFFER=ON).
  191.    * Disable IDSR sensitivity (MODE IDSR=OFF)
  192.    * Disable any output flow control (MODE OCTS=OFF,ODSR=OFF)
  193.  
  194. Of the three, I generally prefer the former, but you may have reasons to do
  195. one of the latter two.  By explicitly setting the buffering on, you will
  196. override the rules above that adjust the receive and transmit triggers.  What
  197. this means is that you may receive extraneous data if DSR is actually being
  198. used to signal input and that if the modem asks the driver to stop sending
  199. data (CTS), it may still receive up to 15 more characters.
  200.  
  201. I don't think either of these problems should hit most people using modems
  202. today.  I believe most modems hold DSR high while they are on (or at least are
  203. configurable to do this), and most modems that handle hardware flow control
  204. (RTS/CTS) drop CTS before they are absolutely out of room.  For example, the
  205. USR Courier v.32bis modem I have has a transmit buffer of 1.5K (3.25K for
  206. error control connections) and drops CTS when the buffer is 90% full (plenty
  207. of room for 15 extra characters).  But of course, for a specific case the
  208. second or third choice can be made, which will make better use of the 16550
  209. than the default settings, but not the best.
  210.  
  211.  
  212. Some experiments
  213. ----------------
  214.  
  215. Just to see if any of the stuff I was learning seemed to apply, I ran some
  216. quick tests.  Nothing extremely scientific - just a couple of quick file
  217. transfers.
  218.  
  219. Using a SLIP connection (TCP/IP over a serial line), with USR v.32bis modems
  220. on either end, I transferred a reasonably sized (115K or so) file down from
  221. a workstation.  My COM port was set at 38.4K.  The transfer was from the
  222. workstation back to my machine so I was mostly testing the receive
  223. characteristics although the program used (FTP) does transmit data during the
  224. transfer.
  225.  
  226. I tested using both the normal COM port settings (plus RTS=HS), and then with
  227. BUFFER=ON rather than AUTO.  Also, I first ran the transfers without anything
  228. else occurring on the system, and then re-ran the same transfers with a PM
  229. monitor (one of the ones from ftp-os2 - pmload11.zoo).  The results were
  230. interesting:
  231.  
  232.     
  233.        FTP Transfer Time (binary mode, size = 114688 bytes)
  234.    MONITOR    BUFFER        Time (s)    Rate (cps)    Load (%)
  235.    ---------------------------------------------------------------------
  236.    No        Auto        41        2797        N/A
  237.    No        On        41        2797        N/A
  238.  
  239.    Yes        Auto        53        2164        98-100
  240.    Yes        On        41        2797        82-86
  241.  
  242.  
  243. When nothing else was running, BUFFER didn't really make much of a difference.
  244. I guess this just meant that my machine itself was fast enough to keep up with
  245. an interrupt a character in general.  I presume though (given the next set of
  246. results) that the load on the system in the On mode was much less.
  247.  
  248. When something was running (even the load program, as a PM program, takes up
  249. CPU time and interferes with running applications - I had it iconized, so it
  250. had to update the icon each second), things were very different.  In Auto
  251. mode, I got a much worse transfer time, and my system load was pretty much
  252. pegged at 100%.  In On mode, I got as good a transfer time as when nothing
  253. else was running, but at a much smaller load on the machine.
  254.  
  255. So I think this is pretty strong evidence that using BUFFER=ON is very
  256. different than BUFFER=AUTO when the other signaling settings are using their
  257. default values.
  258.  
  259.  
  260. Virtual COM Driver (DOS Boxes)
  261. ------------------------------
  262.  
  263. After reading about VCOM (of which little is written), I don't see a magic
  264. pill for DOS box users, other than that a BUFFER=ON setting should help lower
  265. the CPU load and make it easier to keep the virtual interrupt rate up in
  266. the DOS environment.
  267.  
  268. There was one discovery I did make however, that may help some people out.
  269. VCOM supports two modes of accessing the COM ports - either through BIOS
  270. calls or via virtual I/O ports.  The virtual I/O ports only emulate the
  271. lower end INS8250 UART, and as others have noted, the virtual interrupt rate
  272. is limited to around 1000Hz or so.
  273.  
  274. Since I figured it had something to do with the virtual I/O ports that was
  275. causing the most problem with kermit, I reset kermit to use BIOS1 as its
  276. method for accessing the COM port.  Although access through the BIOS is
  277. technically limited to 9600 baud maximum, I was able to run kermit without a
  278. failure, including file downloads.  When letting kermit use the virtual I/O
  279. port, I'd generate traps at rates even as low as 2400 baud.
  280.  
  281. I think this behavior arises from the fact that when the application is
  282. controlling the hardware directly, it is issuing a lot more I/O requests to
  283. the virtual I/O port that must be handled by VCOM.  With the BIOS interface,
  284. the application basically asks BIOS for a character, and gets them back one at
  285. a time.  Since VCOM goes off to COM to get the character, all of the hardware
  286. flow control and buffering used by COM is available to VCOM, and the DOS
  287. application doesn't have to concern itself with anything.
  288.  
  289. So - if someone else is trying to run a COM program in a DOS box and it can
  290. use BIOS to access the COM port rather than trying to run the hardware itself
  291. you may be able to get it working reasonably.  At the very least, it gave me a
  292. way to test the DOS version of kermit some of my users use from home at a
  293. reasonable speed (although not as high as I would like) from within a DOS box.
  294.  
  295.  
  296. Summary
  297. -------
  298.  
  299. An important aspect of the support for 16550 UARTs within the OS/2 2.0 COM
  300. driver is the interaction between various modem control handshaking settings
  301. and the automatic control of extended buffering.  In particular, several of
  302. the default COM port settings (IDSR=ON,OCTS=ON,ODSR=ON) when automatic control
  303. (BUFFER=AUTO) is enabled force the driver not to use the enhanced buffering of
  304. the 16550, and instead generate interrupts for each character transmitted or
  305. received.  This can decrease performance and definitely places a heavier load
  306. on the machine.
  307.  
  308. The easiest way to solve this is to use a setting of BUFFER=ON rather than
  309. BUFFER=AUTO, as long as it won't cause problems overrunning your modem or
  310. receiving extraneous information (see "Improving Settings" above).  I don't
  311. think many users will encounter a problem if they make these changes.  From
  312. my experiments, switching to BUFFER=ON can decrease the load on a 16MHz 386
  313. by at least 15%, while allowing the same transfer rate on a busier system.
  314.  
  315. For the DOS Box, one hint to users trying to get reasonable performance out of
  316. DOS COM applications - BUFFER=ON may also help this situation, but if you can
  317. live with 9600 baud, and your application supports using the BIOS interface to
  318. the COM port, try using that mode.  You may be to run the application
  319. successfully at higher data rates through the emulated BIOS interface than if
  320. the application tries to use the emulated COM hardware directly.
  321.  
  322.  
  323. I hope someone else finds this information useful - I know it's helped me to
  324. get a better handle on how OS/2 manages the COM port, and how various settings
  325. affect its use of the capabilities of my 16550 UARTs.
  326.  
  327.  
  328. --
  329. -- David
  330. --
  331. /-----------------------------------------------------------------------\
  332.  \              David Bolen             \  Internet: db3l@ans.net      /
  333.   |   Advanced Network & Services, Inc.   \   Phone: (914) 789-5327   |
  334.  / 100 Clearbrook Road, Elmsford, NY 10523  \   Fax: (914) 789-5310    \
  335. \-----------------------------------------------------------------------/
  336.