home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / DESQVIEW / MISC / DESQCOMM.ZIP / COMMPROG.TEC
Encoding:
Text File  |  1992-03-16  |  17.4 KB  |  323 lines

  1. ID:CO Communications Programs and DESQview
  2. Quarterdeck Technical Note #237
  3. by Michael Bolton
  4. March 16, 1992
  5.  
  6. DESQview provides true multitasking on any DOS PC in the Intel 86 processor
  7. family, and on compatibles.  Users of communications software find this
  8. feature particularly appealing, since other work can be done while large files
  9. are being uploaded or downloaded.  The communications link remains unbroken
  10. without sacrificing the entire computer to the on-line session.
  11.  
  12. There are a number of considerations involved with using communications
  13. software under DESQview.  Many of these issues are complicated by the fact
  14. that communications technology, and all of the various parameters which
  15. surround it, can seem complex and obscure.
  16.  
  17.  
  18. Q. What are COM ports and IRQs?  How do they relate to each other?
  19.  
  20. A serial port is a piece of hardware which can be used to move information to
  21. and from the machine.  (When files or other forms of information are being
  22. transferred FROM a machine, that machine is said to be "uploading"; when files
  23. are being transferred TO a machine, that machine is "downloading".)  Unlike
  24. parallel ports, which move information eight bits at a time (as a multilane
  25. freeway moves cars), serial ports move data one bit at a time (as a single
  26. lane roadway).  The initial design specification for the IBM PC called for a
  27. single serial port, and this port was assigned a hardware Interrupt ReQuest
  28. line, or IRQ -- very simply, a means of notifying the processor that attention
  29. to a hardware device is required.  When an IRQ is asserted (or signalled), a
  30. processor interrupt, also known as a software interrupt, is called. 
  31. Essentially, whenever a program or a piece of hardware asserts an interrupt,
  32. it asks the processor to run a subroutine.   The processor runs a bit of code,
  33. called an "interrupt handler", and then returns to where it was before. In the
  34. case of a serial port that is receiving data, each byte coming into the serial
  35. port causes a processor interrupt to be generated.  The processor stops
  36. whatever it's doing and calls the interrupt handler, which inspects the data
  37. at the serial port, and performs the appropriate action.  In the case of
  38. high-speed communications (i.e., greater than 2400 bytes per second, or 2400
  39. bps), this can be happening on the order of tens of thousands of times a
  40. second.
  41.  
  42. Note that we have three things to keep track of here:  when something comes in
  43. through (1) a serial port, it signals the processor's attention via (2) an
  44. IRQ.  When the processor receives an IRQ, it executes a particular (3)
  45. software interrupt.
  46.  
  47. An interrupt of higher priority can take immediate precedence over one of
  48. lower priority; that is, an interrupt can interrupt another interrupt!  Other
  49. pieces of hardware -- the keyboard and the system timer -- were seen as being
  50. of potentially greater urgency than the communications port.  Consequently,
  51. they were given IRQ lines with lower numbers, indicating higher priority. 
  52. Here's where life begins to get a little miserable:  COM 1 was thus assigned
  53. to IRQ 4 at this time, and IRQ 4 was set up to call software interrupt 0C hex
  54. (12 decimal).  So: COM1, using IRQ4, calls INT 0C.
  55.  
  56. Closer to the release date of the original PC, the designers found that they
  57. had an IRQ line available, nothing to put on it, and at least a notion that it
  58. might be desirable to have two serial ports on the machine.  COM 2 was
  59. therefore planned.  The next free available IRQ was... IRQ 3 -- it had not yet
  60. been assigned to a piece of hardware, although it had been assigned a
  61. processor interrupt.  So:  COM 2 was assigned to IRQ 3, which calls INT 0Bh.
  62.  
  63.  
  64.  
  65. Later still, with mice and modems proliferating, and adventurous users
  66. desiring more serial ports, the specs were augmented yet again.  Two more
  67. serial ports (named COM 3 and 4) were clearly necessary, but there were no
  68. Interrupt ReQuest lines available by which they could signal the processor
  69. that they needed attention.  Consequently, it was decided that COM 3 and COM 4
  70. would SHARE IRQs with COM 1 and COM 2.  That is COM 3 would be given IRQ 4,
  71. and COM 4 would be given IRQ 3.  The chart makes this a bit easier to see.
  72.  
  73. Serial Port     IRQ     INT Hex (Decimal)
  74. ===========     ===     =================
  75.   COM 1          4         0C    (12)
  76.   COM 2          3         0B    (11)
  77.   COM 3          4         0C    (12)
  78.   COM 4          3         0B    (11)
  79.  
  80. Note that it is possible to have a system configured differently.  Many I/O
  81. cards allow the user to associate communications ports with different IRQs.
  82. However, the above are the default settings and are quite typical.  For
  83. information on systems using more than two serial ports, you may require the
  84. services of a FOSSIL driver.  This allows serial ports and IRQs to be
  85. "multiplexed", or shared.  Information on FOSSIL drivers can be found on many
  86. bulletin board systems and in some books on online communications.
  87.  
  88.  
  89. Q. Does DESQview support serial communications programs?
  90.  
  91. As stated above, DESQview's support of multitasking makes it ideal for those
  92. who wish to do other things while downloading is going on.  DESQview fully
  93. supports high-speed communications, and provides a number of features for the
  94. special handling that communications programs require.
  95.  
  96. Q. How should DESQview be set up for communications?
  97.  
  98. A. "Setup DESQview" Settings
  99.  
  100. Several settings are worthy of note in your overall DESQview setup.  The most
  101. important two are found in the Setup DESQview / Advanced Options / Performance
  102. section.
  103.  
  104.  
  105. 1) Optimize Communications should be set to Y.  This rotates the priority of
  106.    the IRQs, which by default are given priority equivalent to their numbers.
  107.    (Recall that the system timer is on IRQ 0  -- the lowest number and highest
  108.    priority -- and the keyboard uses IRQ 1.)  When Optimize Communications is
  109.    set to Y, the priority of IRQs is rotated, such that IRQ 2 typically gets
  110.    top priority (unless there is a mouse attached), 3 is next, and so on, with
  111.    0 and 1 receiving relatively low priority.  When DESQview sees a mouse
  112.    attached to IRQ2, DESQview gives IRQ3 top priority, on the assumption that
  113.    the that if you want to optimize communications, you want the serial ports
  114.    to receive top priority.
  115.  
  116.  
  117.  
  118.    Optimize Communications can be set to a number as well; the
  119.    number represents the IRQ (NOT the serial port) which is to be receive the
  120.    greatest priority.
  121.  
  122.  
  123.  
  124.    If you are having difficulties with a modem on COM1, for example, it
  125.    might be worthwhile setting Optimize Communications to 4 (for IRQ 4,
  126.    representing COM 1).  In this case, IRQ 4 will get top priority, IRQ
  127.    5 will be next, and so on.  Again, note that since the priority of
  128.    the interrupts is merely rotated, and not reordered, setting Optimize
  129.    Communications to 4 will give IRQ 4 the highest and IRQ 3 the lowest
  130.    priority.  This is ideal for systems on which the modem is on COM 1
  131.    (IRQ 4) and the mouse is on COM 2 (IRQ 3).  Without Optimize
  132.    Communications, note that, in this case, the mouse would actually
  133.    have higher priority than the modem!
  134.  
  135.    On a system with two modems -- one on COM 1 (IRQ 4) and the other on
  136.    COM 2 (IRQ 3), an Optimize Communications setting of 4 would be
  137.    terrible; IRQ 3 would drop to the bottom of the priority list, and
  138.    thus the modem attached to COM2 could lose some of the incoming data.
  139.  
  140. 2) It is important to make sure that the processor "sees" the
  141.    communications port frequently, since the bytes coming in to the
  142.    serial ports must be handled before the buffer on the communications
  143.    port overflows.
  144.  
  145.    DESQview allocates time to each program via "Clock Ticks".  A tick is
  146.    regulated by the system timer, which ticks 18.2 times every second,
  147.    regardless of the type of processor.  DESQview runs a foreground
  148.    application for n clock ticks, (where n is the setting under Setup
  149.    DESQview / Advanced Options / Performance / Clock Ticks / Foreground)
  150.    and runs EACH background application for the number of clock ticks
  151.    allocated to the background setting.  The time in which an
  152.    application runs is called a time slice.  An application is suspended
  153.    while other programs are running in their time slices.  (Naturally, a
  154.    program will not get a background time slice if it has been set not to
  155.    run in background.)
  156.  
  157.    As an example, assume that we have four processes running on our
  158.    machine, one of which is a communications program, and that
  159.    DESQview's clock ticks setting is at its default 9 and 3.  In this
  160.    case, the foreground application will have the processor's attention
  161.    for 9 ticks (9/18.2 seconds), and two background processes will have
  162.    3 ticks each (3/18.2 + 3/18.2 seconds), in between the 3 ticks
  163.    allocated to our communications program.  This means that our
  164.    communications program is getting the processor's attention once per
  165.    second, for about 1/6 of a second; thus, the processor is otherwise
  166.    occupied 5/6 of a second.  This is a long time for a communications
  167.    program to be absent from the processor's attention.  Bytes coming in
  168.    on the serial port can overflow the one-byte buffer in the standard
  169.    UART chip, thereby causing some bytes to be lost.  Depending on the
  170.    robustness of your communications software and the protocol it uses,
  171.    lost bytes will result in a delayed transfer while the errors are
  172.    corrected, corrupted files, or an aborted download.  The section
  173.    below on the 16550A UART will have more to say on this subject.
  174.  
  175.    In fact, the situation isn't usually quite as bad as all that, since
  176.    not every program takes its full slice all the time.  DESQview-aware
  177.    programs inform DESQview whenever they have finished a task, and can
  178.  
  179.  
  180.  
  181.    therefore be suspended until there's more work to do.  Programs that
  182.    have been written with no particular consideration for DESQview, are
  183.    monitored while they are in the background -- when they do not have
  184.    access to the keyboard.  If such a program is waiting for keyboard
  185.    input, DESQview will abridge that program's time slice, and will not
  186.    switch back to it until that program is put to the foreground again.
  187.    And in fact, the situation is STILL better than the above might
  188.    suggest.  DESQview manages all of the interrupt request lines by
  189.    reprogramming the programmable interrupt controller chip.  When a
  190.    hardware interrupt is asserted, DESQview determines which process
  191.    needs urgent attention, and passes control to that program's
  192.    interrupt handler.  DESQview also prevents timer, mouse, and keyboard
  193.    interrupts from interfering while a communications interrupt is being
  194.    handled, thus giving your program time to catch up and manage the
  195.    incoming data.  If you have programs that are running in background,
  196.    they may be suspended temporarily to improve the smoothness of
  197.    communications; at the DESQview menu, type Rearrange / Tune
  198.    Performance / Runs in Background / No.  If, despite all this, data is
  199.    still coming in faster than it can be managed, adding a larger buffer
  200.    to your serial port might help; see the section on the 16550A UART
  201.    below.
  202.  
  203.  
  204. B. DVP Settings
  205.  
  206. Three settings in your program's DESQview Program Information File
  207. (accessed by the Change a Program Menu) are crucial for communications.
  208.  
  209. 1) A communications program must be set to use the serial ports.  If the
  210.    modem uses COM 1, Uses Serial Ports can be set to 1.  If the modem
  211.    uses COM 2, Uses Serial Ports can be set to 2.  If the modem is on
  212.    COM 3 or COM 4, or if you are at all unsure about which serial port
  213.    the modem is on, set Uses Serial Ports to Y.  See Quarterdeck
  214.    Technical Note #145 (COM3N4.TEC -- COM Ports and DESQview) for more
  215.    information on this.
  216.  
  217.    In a given window, DESQview can hide a port by setting its I/O port
  218.    address to 0, rather than to its actual address.
  219.  
  220.  When Uses Serial Ports is set to    DESQview hides the port address of
  221.  ================================    ==================================
  222.              1                                    COM 2
  223.              2                                    COM 1
  224.              N                               Both COM ports
  225.  
  226.    If a port is hidden in a given window, programs running in that
  227.    window should be unable to access that port.  An exception to this is
  228.    noted below, in the section headed "Programs that initialize the
  229.    serial ports".  DESQview never hides the port address of COM3 or COM4, 
  230.    regardless of the "Uses serial ports" setting.
  231.  
  232. 2) A communications program must be set to run in background.  Valid
  233.    settings for Runs in Background are Y, N, or blank.  If the field is
  234.    left blank, DESQview will continue to run a program in background if
  235.    Uses Serial Ports is set to Y.
  236.  
  237.  
  238. 3) A communications program must be set not to swap out.  Valid settings
  239.    for Can be Swapped Out are Y, N, and blank, but a communications
  240.    program should be set explicitly not to swap out.  If the program is
  241.    swapped out, it will be suspended.  If it is suspended, at very least
  242.    data will be lost, and at worst, a system crash could result.
  243.  
  244. Other settings are important, too.
  245.  
  246. 1) As with all programs running under DESQview, allocating enough memory to
  247.    the program is important.  Many communications programs call on
  248.    external programs -- most often to use download protocols which are
  249.    not built-in to the program.  At the point where the external
  250.    protocol is called, the application will typically need more memory
  251.    than it has been using up to that point.  Take this into account when
  252.    allocating memory usage in the DESQview Change a Program Menu.
  253.  
  254. 2) Communications programs use "protocols" for file transfers -- these
  255.    are schemes which govern how the connected computers relate to each
  256.    other, how the information is organized, what error-checking routines
  257.    are going to be used, and so on.  Communications programs typically
  258.    support at least a few protocols directly, and often provide for
  259.    other protocols to be added externally.  What typically happens is
  260.    that such a program will allow the user to "shell out" to DOS
  261.    temporarily, and start a program which handles the file transfer with
  262.    the desired protocol.
  263.  
  264.    External protocols may cause a window to close prematurely if
  265.    Close on Exit is set to Y.  When an external protocol finishes a file
  266.    transfer, and issues a DOS Terminate Program call, DESQview may close
  267.    the window in which the communications program is running.  If you
  268.    are using an external protocol with your communications software and
  269.    the window closes after a file transfer, try setting Close on Exit
  270.    to N.  If you are using a batch file to load TSRs and a
  271.    communications program within a DESQview window, you will find that
  272.    the window remains open after the batch file has been completed; make
  273.    "exit" the last line of the batch file.
  274.  
  275. 3) A program which writes either graphics or text directly to screen must be
  276.    configured not to do so if it is to run in background without corrupting
  277.    the screen of foreground applications.
  278.  
  279.    a) The ideal is for a program to be "DESQview- or TopView aware".  Such
  280.       programs write directly to screen normally, but write to DESQview's own
  281.       video buffer when running under DESQview.
  282.  
  283.    b) Programs which write directly to screen often have configuration options
  284.       which alter this strategy. Settings of this kind are often referred to
  285.       as "uses DOS calls for screen writes" or "uses BIOS writes", or "do not
  286.       write directly to screen".
  287.  
  288.    c) DESQview 386 is QEMM-386 and DESQview running together on an 80386 or an
  289.       i486 processor.  Programs running under DESQview 386 can be
  290.       "virtualized"; that is, DESQview 386 will intercept and properly manage
  291.       the screen writes of programs that write directly to the video hardware.
  292.  
  293.    If none of these configurations is possible, there are two unpleasant
  294.    prospects.  The first is that the program must be suspended while it is in
  295.    background.  DESQview will suspend a background program that writes
  296.    directly to screen:
  297.  
  298.  
  299.  
  300.    a) if "Runs in Background" is set to N or blank, AND 
  301.    b) if "Uses Serial Ports" is set to N.
  302.  
  303.    Suspending a communications program is unacceptable, since the essence
  304.    of a communications program is to exchange information continuously.
  305.    DESQview will therefore keep running a background program that
  306.    writes directly to screen:
  307.  
  308.    a) if "Runs in Background" is set to Y, OR
  309.    b) if "Runs in Background" is blank AND Uses Serial Ports is Set to 1, 2,
  310.       or Y
  311.  
  312. In this case, the program will continue to write directly to screen while in
  313. background, thus corrupting the display of foreground applications.  If you
  314. are not using DESQview 386, and if your program writes directly to the screen
  315. and cannot be dissuaded from doing so, you will be forced to tolerate the
  316. corrupted display or to change your communications software to a package that
  317. does not write directly to the screen or is DESQview-aware.  See the files
  318. DIRECTLY.TEC and VIRTUALI.TEC for more information on display and
  319. virtualization.
  320.  
  321.   ************************************************************************
  322.   *This technical note may be copied and distributed freely as long as it*
  323.   *is distributed in its entirety and it is not distributed for profit.  *
  324.   *         Copyright (C) 1991-2 by Quarterdeck Office Systems           *
  325.   ************************ E N D   O F   F I L E *************************
  326.  
  327.  
  328.