home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / SYSTEM / MDOSP401.ZIP / MULTIDOS.PRN < prev    next >
Encoding:
Text File  |  1991-10-27  |  150.2 KB  |  4,423 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.                     __________________________________________
  20.                     |                                        | 
  21.                     |                                        | 
  22.                     |        MultiDos Plus (tm) 4.01         | 
  23.                     |                                        | 
  24.                     |        "Multitasking for DOS"          | 
  25.                     |                                        | 
  26.                     |           Shareware Version            | 
  27.                     |                                        | 
  28.                     |                                        | 
  29.                     |           Copyright (c) 1991           | 
  30.                     |                                        | 
  31.                     |                   by                   | 
  32.                     |                                        | 
  33.                     |             Nanosoft Inc.              | 
  34.                     |           13 Westfield Road            | 
  35.                     |            Natick, MA 017              | 
  36.                     |                                        | 
  37.                     |          Voice (508) 651-0091          | 
  38.                     |           FAX (508) 655-8860           | 
  39.                     |           BBS (508) 650-9552           | 
  40.                     |                                        | 
  41.                     |________________________________________|
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.                                  Table of Contents
  70.                                  -----------------
  71.  
  72.  
  73.  
  74.         Introduction                                             1
  75.  
  76.         System Overview                                          2
  77.  
  78.         Getting Started                                          3
  79.  
  80.         Command Line Options                                     5
  81.  
  82.         Operator Commands                                        8
  83.  
  84.         Foreground/Background Program Selection                 17
  85.  
  86.         Executing DOS Commands                                  18
  87.  
  88.         Automatic Startup                                       19
  89.  
  90.         Using MDDEBUG                                           21
  91.  
  92.         The Application Program Interface (API)                 27
  93.  
  94.            Execution Control Functions                          29
  95.  
  96.            Resource Control Functions                           37
  97.  
  98.            Inter-Task Messaging Functions                       42
  99.  
  100.            Event Trigger Functions                              46
  101.  
  102.         Inside MultiDos Plus                                    48
  103.  
  104.         Running with a LIM 4.0 EMS Driver                       53
  105.  
  106.         Using the Math Coprocessor                              56
  107.  
  108.         Useful System Data Structures                           57
  109.  
  110.         Software Interface for Terminal Communication           60
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  134.  
  135.         CHAPTER I
  136.  
  137.         INTRODUCTION
  138.         ------------
  139.  
  140.         MultiDos  Plus  is  a multitasking extension to  MS/PC-DOS  which 
  141.         enables you to run multiple DOS programs simultaneously. In order 
  142.         to use MultiDos Plus you will need an IBM PC/XT/AT or true  clone 
  143.         running  under DOS 3.0 or later operating system.  You will  also 
  144.         need enough memory to contain the operating system, MultiDos Plus 
  145.         (about 64K), and your application programs.
  146.  
  147.         MultiDos  Plus  enables  you to load multiple  programs  in  your 
  148.         system  at the same time and have them all run concurrently using 
  149.         a preemptive multitasking scheduler.  The scheduler provides  for 
  150.         two different types of prioritized scheduling.
  151.  
  152.         Programs  running  under  MultiDos Plus have full access  to  DOS 
  153.         services by means of standard DOS function calls.  Users may  use 
  154.         the  full  range  of DOS commands by  running  COMMAND.COM  under 
  155.         MultiDos Plus.  In addition MultiDos Plus is compatible with most 
  156.         "well behaved" off-the-shelf software available for the IBM-PC. A 
  157.         set  of commands are available to load and execute programs,  set 
  158.         program priorities,  suspend/resume/abort programs and  more.  An 
  159.         Application Program Interface (API) enables user written programs 
  160.         to do the following:
  161.  
  162.           o Change program priority
  163.           o Change time slice interval
  164.           o Run subroutines or functions as separate tasks
  165.           o Execute MultiDos Plus commands from within a task
  166.           o Communicate with other programs
  167.           o Suspend for a timed interval
  168.           o Synchronize resource usage using semaphores
  169.           o Wait on and signal events
  170.  
  171.         MultiDos  Plus  supports  the execution of programs  in  expanded 
  172.         memory using the LIM 4.0 Expanded Memory standard.  In most cases 
  173.         the  program  need not be aware that it is  running  in  expanded 
  174.         memory.
  175.  
  176.         MultiDos  Plus  can  be  run  as a DOS  SHELL  program  or  as  a 
  177.         conventional  EXE  DOS program.  MultiDos Plus and  all  programs 
  178.         running  under  it may be started up automatically by means of  a 
  179.         startup file. With this feature the system can be started with no 
  180.         operator intervention providing a platform for turnkey systems.
  181.  
  182.         Programs  running under MultiDos Plus can access the display  and 
  183.         keyboard by means of standard DOS or BIOS calls.  Each program is 
  184.         assigned a distinct virtual display,  with only the  "foreground" 
  185.         program allowed to write to the real display.  The user may bring 
  186.         any program to the foreground by means of a hot key.
  187.  
  188.         Usually  a  program and task are synonymous under MultiDos  Plus. 
  189.         However,  it is possible for a task to create another task to run 
  190.         in  parallel and share the same code and data  space.  These  are 
  191.         referred  to as internal tasks or threads and are described later 
  192.         in more detail.
  193.  
  194.  
  195.  
  196.                                      (1)
  197.  
  198.  
  199.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  200.  
  201.         SYSTEM OVERVIEW
  202.         ---------------
  203.  
  204.         MultiDos  Plus  is  an EXE program and may be run  from  the  DOS 
  205.         command  line like any other EXE program.  You can exit  MultiDos 
  206.         Plus, and the system will revert back to its normal state.
  207.  
  208.         On startup, MultiDos Plus takes control of the system by altering 
  209.         various  interrupt  vectors  to  point  to  itself  and  also  by 
  210.         obtaining all the system memory. From this point on MultiDos Plus 
  211.         controls  the  loading  and execution  of  application  programs. 
  212.         MultiDos Plus can load programs in accordance with commands typed 
  213.         at  the keyboard,  by other programs already loaded  and  running 
  214.         under MultiDos Plus, or by commands in a special startup file.
  215.  
  216.         MultiDos  Plus  provides true preemptive multitasking  scheduling 
  217.         with  a  choice  of two different  priority  schemes.  Under  the 
  218.         default  scheduling scheme,  CPU time slices are assigned to  the 
  219.         various  programs in a round robin manner.  Programs with  higher 
  220.         priority  (lower priority number) receive more time  slices  than 
  221.         programs with lower priority. The time-slice interval is based on 
  222.         the timer interrupt in the PC and is approximately 55 msecs.  You 
  223.         can  change  the  time-slice interval by making  the  appropriate 
  224.         MultiDos  Plus Application Program Interface (API) call or  by  a 
  225.         command line parameter when MultiDos Plus is started.
  226.  
  227.         MultiDos  Plus  provides an alternative scheduling  scheme  under 
  228.         which the highest priority program in the system continues to run 
  229.         until  it is suspended waiting for some system resource to become 
  230.         available. This scheduling scheme requires that programs be aware 
  231.         that they are running in a prioritized multitasking  environment. 
  232.         It  would  be  necessary for high priority  programs  to  suspend 
  233.         voluntarily,  in order to permit other lower priority programs to 
  234.         run. This scheduling scheme is necessary for many applications in 
  235.         order to guarantee that certain high priority tasks get scheduled 
  236.         in  a  predictable manner to handle real time events.  Using  the 
  237.         alternative  scheduling  scheme requires careful  design  of  the 
  238.         overall system. For most normal situations the default scheduling 
  239.         scheme should be adequate.
  240.  
  241.         Since DOS is not reentrant,  MultiDos Plus controls all access to 
  242.         DOS  system  services on a first come first served  basis.  Tasks 
  243.         need not concern themselves with the details of accessing DOS  in 
  244.         concert with other tasks and can make calls to DOS at any time.
  245.  
  246.         Programs  which  cannot  execute  for  any  reason  (waiting  for 
  247.         keyboard  input,  waiting  for  DOS or  MultiDos  Plus  services, 
  248.         operator suspended, etc.) are not assigned time slices.
  249.  
  250.         MultiDos Plus also controls access to the visible display and the 
  251.         keyboard.  All  programs  under MultiDos Plus including  MultiDos 
  252.         Plus  itself  can  be  in one  of  two  states  -- foreground  or 
  253.         background.  Only  the  foreground  program can  display  on  the 
  254.         monitor  or  read from the keyboard.  At any given time only  one 
  255.         program can be in the foreground state.  If any of the background 
  256.         programs writes to the screen using DOS or BIOS calls, the output 
  257.         is actually written to an "invisible" screen associated with that 
  258.         program. This screen becomes visible if the program is brought to 
  259.  
  260.  
  261.  
  262.                                      (2)
  263.  
  264.  
  265.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  266.  
  267.         the  foreground.  You  can swap programs between  foreground  and 
  268.         background  by  means of commands entered at the keyboard  or  by 
  269.         means  of MultiDos Plus API calls.  It is important to note  that 
  270.         background  programs do continue to run,  even if you do not  see 
  271.         them do anything.
  272.  
  273.         MultiDos Plus software consists of the following components:
  274.  
  275.            MULTIDOS.EXE - the multitasking kernel.
  276.            MDBIO10.EXE - a display driver TSR which is automatically 
  277.  
  278.         loaded  by  MultiDos  Plus  on  startup.  This  driver  redirects 
  279.         interrupt 10H display calls issued by background programs to  the 
  280.         appropriate virtual screens.
  281.  
  282.            MDHLP - an ASCII text file containing online help information.
  283.            MDDEBUG.EXE - a monitor/debugger program useful for debugging 
  284.                          application programs running under MultiDos Plus.
  285.  
  286.         GETTING STARTED
  287.         ---------------
  288.  
  289.         Install  MultiDos Plus in your system by copying the distribution 
  290.         diskette to any directory in your system.  We recommend that this 
  291.         directory be specified in your DOS PATH environment variable.
  292.  
  293.         The  distribution diskette includes a number of sample  programs. 
  294.         This section describes how to bring up MultiDos Plus and run  two 
  295.         of the sample programs.
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                                      (3)
  329.  
  330.  
  331.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  332.  
  333.         Change   your  current  disk  and  directory  to  the   directory 
  334.         containing the MultiDos Plus files.  From the DOS prompt, perform 
  335.         the following steps:
  336.  
  337.           1) Type MULTIDOS
  338.              MultiDos Plus is started, and you should see the MultiDos 
  339.              Plus prompt.
  340.           2) Type RM 128
  341.              This command assigns 128K of memory to the next task.
  342.           3) Type RU DEMO1
  343.              The DEMO1 program is loaded into a 128K memory block.
  344.           4) Type RM 64
  345.              Assign 64K of memory to the next task.
  346.           5) Type RU DEMO2
  347.              The DEMO2 program is loaded into a 64K memory block.
  348.  
  349.         The  ALTZ hot key (ALT and Z simultaneously pressed) may be  used 
  350.         to  bring  any program to the foreground.  The ALTZ hot key  also 
  351.         switches  you  from an application program to the  MultiDos  Plus 
  352.         command interpreter.
  353.  
  354.         Typing a ? gives you a list of valid MultiDos Plus commands.
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                                      (4)
  395.  
  396.  
  397.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  398.  
  399.         CHAPTER II
  400.         ----------
  401.  
  402.         COMMAND LINE OPTIONS
  403.         --------------------
  404.  
  405.         MultiDos  Plus may be started by simply typing MULTIDOS when  you 
  406.         have  a  DOS prompt on your screen,  or it may  be  automatically 
  407.         started from the autoexec.bat file,  or you may specify  MultiDos 
  408.         Plus  to  be the startup DOS SHELL.  If MultiDos Plus is  started 
  409.         with  no command line arguments,  certain default parameters  are 
  410.         assumed for the system. These parameters may be modified by means 
  411.         of optional command line arguments.  Certain arguments require an 
  412.         additional parameter. For example:
  413.  
  414.             MULTIDOS /NALTZ /NUMTCB 5
  415.  
  416.         This  will start MultiDos Plus with the hot key disabled and  the 
  417.         number of programs in the system limited to 5.
  418.  
  419.         The  remainder of this section lists the command line options and 
  420.         a detailed description of each.  NOTE:  All options begin with  a 
  421.         slash  (/).  Command line options or arguments may be entered  in 
  422.         upper or lower case.
  423.  
  424.         /AUTO [startup file name]
  425.  
  426.         The  /AUTO  option allows you to specify the path name of a  file 
  427.         which  contains  MultiDos Plus commands.  If this option  is  not 
  428.         specified,  a  file called AUTO.MTX is assumed to be the  startup 
  429.         batch file.  If the startup batch file is not present, the system 
  430.         comes  up  in the interactive mode permitting the user  to  enter 
  431.         MultiDos  Plus  commands  manually.  See  the  Automatic  Startup 
  432.         section in this chapter for more information.
  433.  
  434.         /CTX
  435.  
  436.         The  /CTX option allows programs running under MultiDos  Plus  to 
  437.         maintain unique current directory and current disk context.  That 
  438.         is, a program doing a change directory will have no effect on the 
  439.         current  directories  of other programs.  NOTE:  The use of  this 
  440.         command adds a significant overhead to each DOS file system  call 
  441.         because  of the amount of context information which must be saved 
  442.         and  restored.  The default is to have the current directory  and 
  443.         current  disk as global values which can be changed by any  task. 
  444.         If  your programs use absolute path names or if your programs  do 
  445.         not  change  the current directory or disk,  this option  is  not 
  446.         required.  Using this option has performance as well as a  memory 
  447.         overhead (400 bytes per task).
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.                                      (5)
  461.  
  462.  
  463.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  464.  
  465.         /EMMPGS [# of 16K EMM pages]
  466.  
  467.         This option should only be used in a system with LIM 4.0 expanded 
  468.         memory.  Use  the /EMMPGS option to limit the size of the LIM 4.0 
  469.         expanded memory page frame created by MultiDos Plus for  expanded 
  470.         memory program loading.  The value specified is the number of 16K 
  471.         pages to allocate to the frame.  If this option is not specified, 
  472.         MultiDos  Plus  will create the biggest possible page  frame  for 
  473.         program loading.
  474.  
  475.  
  476.         /MAPALL
  477.  
  478.         This option should only be used in a system with LIM 4.0 expanded 
  479.         memory.   The   /MAPALL  option  will  cause  MultiDos  Plus   to 
  480.         permanently map the LIM page frame (usually at segment C000H) and 
  481.         make this part of the conventional memory in the system. NOTE: Do 
  482.         not use this option if you plan on running applications which use 
  483.         LIM  driver  calls  and explicitly map LIM  memory.  By  default, 
  484.         MultiDos Plus will map all other "holes" in the first megabyte as 
  485.         conventional  memory permitting access to a substantially  larger 
  486.         amount of conventional memory.  This option has no impact on  the 
  487.         size   and  function  of  the  MultiDos  Plus  Page  Frame  where 
  488.         applications are loaded and executed.
  489.  
  490.         /NALTZ
  491.  
  492.         Use the /NALTZ option to disable the ALTZ hot key  feature.  This 
  493.         option  is  most  useful in turnkey systems where it may  not  be 
  494.         desirable to allow the user access to the MultiDos Plus commands. 
  495.         A  turnkey  system would use the FG command in  the  AUTO.MTX  or 
  496.         user-specified  startup file to establish a foreground program at 
  497.         system  startup,  preventing the system operator from  using  any 
  498.         MultiDos Plus commands.
  499.  
  500.         /NOECHO
  501.  
  502.         The  /NOECHO  option will inhibit the echoing of the commands  in 
  503.         the startup file.
  504.  
  505.         /NOPROMPT
  506.  
  507.         The  /NOPROMPT  option will inhibit the display of  the  MultiDos 
  508.         Plus command prompt when MultiDos Plus is in the foreground.
  509.  
  510.         /NOREDIRECT
  511.  
  512.         Use  this  option to prevent redirection of standard  output  and 
  513.         input to and from the communication ports for tasks started  with 
  514.         the  COMM  command.  This  option  is  useful  only  for  certain 
  515.         specialized communication programs.
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.                                      (6)
  527.  
  528.  
  529.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  530.  
  531.         /NUMTCB [# of TCBs to allocate]
  532.  
  533.         MultiDos  Plus allocates a structure called a  TCB for each task. 
  534.         All  the  TCBs are initially allocated when MultiDos  Plus  first 
  535.         starts. The default number allocated is 12 which is enough for 10 
  536.         tasks.  MultiDos  Plus  itself  requires two  TCBs  for  its  own 
  537.         internal use.  The rest are available for user programs. Each TCB 
  538.         occupies  224  bytes  of  memory.   Allocating  unnecessary  TCBs 
  539.         decreases  the memory available for application  programs.  Also, 
  540.         use  of  the /CTX option increases the size of each TCB by  about 
  541.         400 bytes. Up to 64 TCBs may be allocated.
  542.  
  543.  
  544.         /PR [level]
  545.  
  546.         MultiDos  Plus  provides  two  different  prioritized  scheduling 
  547.         schemes.  The /PR command is used to override the default  scheme 
  548.         of  a  simple round robin.  The [level] is a value from 0 to  255 
  549.         which is the priority level initially assigned to tasks when they 
  550.         are  loaded.  The  scheduling scheme invoked by  the  /PR  option 
  551.         allows the task with the highest priority to execute until a task 
  552.         of  greater  priority is scheduled or the running  task  suspends 
  553.         itself.  Tasks  of equal priority are still scheduled in a  round 
  554.         robin  manner  within  their  own  priority  level.   NOTE:  Both 
  555.         scheduling schemes permit the use of 256 priority levels.
  556.  
  557.         See  the  section on Inside MultiDos Plus in Chapter V  for  more 
  558.         details on the two scheduling schemes.
  559.  
  560.         /TSL [interval designator]
  561.  
  562.         The  /TSL option will tell MultiDos Plus to preset the time-slice 
  563.         interval at startup. If this option is not specified, the default 
  564.         interval   will  be  set  to  55  milliseconds.   The   [interval 
  565.         designator] is a single character and must be one of 2,  4,  8, A 
  566.         or  B.  See  the  API function code 10 for more  details  on  the 
  567.         effects of changing the time-slice interval.  The following table 
  568.         shows the relationship between the /TSL parameters and the length 
  569.         of the time slice.
  570.  
  571.         Parameter     Interval Length (milliseconds)
  572.             2                  27.5
  573.             4                  13.75
  574.             8                   6.88
  575.             A                   3.44
  576.             B                   1.72
  577.  
  578.         Any  other values will result in an error message,  and  MultiDos 
  579.         Plus will terminate.
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.                                      (7)
  593.  
  594.  
  595.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  596.  
  597.         OPERATOR COMMANDS
  598.         -----------------
  599.  
  600.         A  set of commands called Operator Commands control  the  loading 
  601.         and execution of application programs under MultiDos Plus.  These 
  602.         commands are used to load,  execute, abort, suspend, and restrict 
  603.         the memory usage of the programs. A special startup file may also 
  604.         contain these commands to automatically load and execute programs 
  605.         when MultiDos Plus is started.
  606.  
  607.         Commands  may  be entered in upper or lower case,  and  you  must 
  608.         terminate each command with a carriage return.
  609.  
  610.         It  is possible for a running task to issue operator commands  by 
  611.         using  the  Application  Program Interface.  See the  section  on 
  612.         Execution  Control  Functions  in  Chapter  IV  for   details.The 
  613.         commands  are  grouped into four sections.  The commands  in  the 
  614.         first  section  are those you may need to specify before  loading 
  615.         and  executing  a  program.  All commands  in  this  section  are 
  616.         optional since they all have default values associated with them. 
  617.         The  second  section consists of a single command (RU)  which  is 
  618.         actually  used to load the program.  The third section deals with 
  619.         commands  to control the execution of programs,  and  the  fourth 
  620.         section contains miscellaneous commands.
  621.  
  622.         Preload Commands
  623.         ----------------
  624.  
  625.         As  noted earlier,  all commands in this section are optional and 
  626.         are  used  to override defaults used in loading a  program  under 
  627.         MultiDos Plus. All parameters revert back to the default state as 
  628.         soon  as a program is loaded.  Some commands in this section  are 
  629.         provided  only to undo the effects of a previous command and  are 
  630.         infrequently used.
  631.  
  632.         AM - Additional Memory
  633.  
  634.         When MultiDos Plus loads a program,  the minimum amount of memory 
  635.         required  to load the program is computed.  If the AM command  is 
  636.         used, the value specifed is added to the minimum amount of memory 
  637.         required  to  load  the program.  Enter  the  command  using  the 
  638.         following syntax:
  639.  
  640.              AM <additional memory required in K>
  641.  
  642.         The  <additional  memory  required in K> parameter is  a  decimal 
  643.         value in units of 1,024 bytes.
  644.  
  645.         CD - Change the Current Directory
  646.  
  647.         The  CD  command  is provided so that the  user  can  change  the 
  648.         current  working directory for MultiDos Plus.  Other DOS internal 
  649.         commands  are  available  only if  COMMAND.COM  is  loaded  under 
  650.         MultiDos Plus.
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.                                      (8)
  659.  
  660.  
  661.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  662.  
  663.         CMP - Program Uses Conventional Memory Only
  664.  
  665.         Use  the  CMP  command  to undo the effects  of  a  previous  XMP 
  666.         command.  The  CMP command indicates that the next loaded program 
  667.         will not make any calls to a LIM 4.0 expanded memory manager. CMP 
  668.         is  the default unless an XMP command has  been  executed.  NOTE: 
  669.         This  command  has  no  bearing on whether the  program  runs  in 
  670.         expanded memory or not but only instructs MultiDos Plus that  the 
  671.         program will not use expanded memory on its own.
  672.  
  673.  
  674.         COMM - Specify the CRT Port for the Program
  675.  
  676.         Use  the COMM command to specify a CRT communication port for the 
  677.         program's  standard input and output.  This will  cause  MultiDos 
  678.         Plus to redirect the program's standard keyboard and display data 
  679.         to and from the communications port. The command syntax is:
  680.  
  681.             COMM <port> <init-parms>
  682.  
  683.         The  parameter <port> specifies the communication port where  the 
  684.         CRT is connected.  A value of 1 designates COM1, value of 2 COM2, 
  685.         etc.   The   number  of  COM  ports  supported  depends  on   the 
  686.         communications  driver  in your system.  The  <init-parms>  is  a 
  687.         hexadecimal  value  used to initialize the port when the task  is 
  688.         loaded and is used to set the baud rate,  parity,  etc.  See  the 
  689.         Initialize   Port  function  under  the  Software  Interface  for 
  690.         Terminal Communication section in Chapter V for more information. 
  691.         The <init-parms> value corresponds to the contents of register AL 
  692.         documented in that section.
  693.  
  694.         It  is IMPORTANT that the NANSI command be executed for the  task 
  695.         after  the  task is loaded.  The built-in ANSI.SYS  functions  in 
  696.         MultiDos  Plus do not support programs running on CRTs  connected 
  697.         to your PC.  Therefore,  it is necessary to disable this function 
  698.         for programs running on CRTs.
  699.  
  700.         DI - Allocate Background Display Memory
  701.  
  702.         When the next task is loaded by the RU command,  the task will be 
  703.         given  a  display  memory for  background  display  output.  This 
  704.         command  is rarely needed since this is the  default  mode.  This 
  705.         command  is provided so that you can undo an ND command typed  by 
  706.         mistake.
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.                                      (9)
  725.  
  726.  
  727.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  728.  
  729.         IRQ - Associate the LIM Map of a task with an External Interrupt
  730.  
  731.         The  IRQ  command  tells  MultiDos Plus  that  when  an  external 
  732.         interrupt  occurs the LIM map associated with the program  should 
  733.         be  mapped  before  the  ISR associated  with  the  interrupt  is 
  734.         invoked.  When the ISR returns, the original map is automatically 
  735.         restored.  This  command  is  required only for  expanded  memory 
  736.         programs performing asynchronous I/O with external devices.
  737.  
  738.         The syntax for the IRQ command is:
  739.  
  740.             IRQ <level>
  741.  
  742.         <level>  is  a  number from 1 to 15 and  indicates  the  hardware 
  743.         interrupt to be mapped.  A value of 1 will map interrupt vector 9 
  744.         which is normally the keyboard hardware interrupt.  Values 1 thru 
  745.         7 map to vector numbers <level> + 8,  and values 8 thru 15 map to 
  746.         vector numbers <level> + 68H.
  747.  
  748.         LC - Load in Conventional Memory
  749.  
  750.         The  LC command tells MultiDos Plus to load the next program into 
  751.         conventional memory.  On systems with no expanded memory this  is 
  752.         the  default.  If a LIM 4.0 board and driver are present in  your 
  753.         system,  programs  are loaded in expanded memory by default.  Use 
  754.         this command only if you have LIM 4.0 in your system and you wish 
  755.         to load your program in conventional memory.
  756.  
  757.  
  758.         LO - Program Execution Starts Only After Foreground Selection
  759.  
  760.         By default,  programs loaded under MultiDos Plus are not  started 
  761.         until  the  program is brought to the foreground the  very  first 
  762.         time. The XQ command, described later, permits a program to start 
  763.         running  as soon as it is loaded.  The LO command is provided  to 
  764.         undo a previous XQ command.
  765.  
  766.         LX - Load Program in Expanded Memory
  767.  
  768.         Use the LX command to reverse the effect of an LC command. The LX 
  769.         command  tells  MultiDos  Plus  to load  the  next  program  into 
  770.         expanded  memory.  This command is only meaningful if your system 
  771.         has expanded memory and a LIM 4.0 driver.  If LIM 4.0 is present, 
  772.         the  default  is to load programs into LIM memory  unless  an  LC 
  773.         command is entered.
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.                                      (10)
  791.  
  792.  
  793.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  794.  
  795.         ND - No Display Memory 
  796.  
  797.         If  the next task to be loaded will not perform any output to the 
  798.         screen,  the ND command can be entered to inhibit the  allocation 
  799.         of  a  background display memory buffer for the task.  This  will 
  800.         save either 4K or 16K depending on the display adapter. If the ND 
  801.         command  is used,  the XQ command must also be used in  order  to 
  802.         start  running  the program.  This is necessary because  programs 
  803.         with  no  display  memory cannot be brought  to  the  foreground. 
  804.         Programs  with no display memory will not show up when  the  ALTZ 
  805.         hot key is used.
  806.  
  807.         RM - Reserve Memory
  808.  
  809.         When  MultiDos Plus loads a program,  it automatically determines 
  810.         the  amount of memory to assign to the program.  This is done  by 
  811.         examining  the size of the program file and,  in the case of  EXE 
  812.         programs,  the  information  in the  EXE  header.  However,  many 
  813.         programs  request  additional  memory by making  the  DOS  memory 
  814.         allocation calls. Programs written in high level languages may do 
  815.         so  for stack and heap space even if you find no explicit  memory 
  816.         calls in your program.  It is important to note that this  memory 
  817.         is  allocated  only  from  the initial memory  reserved  for  the 
  818.         program.  Therefore,  many  programs  may not  operate  correctly 
  819.         unless sufficient memory is reserved for the program.  The amount 
  820.         of  memory needed by a program may be determined by  reserving  a 
  821.         large  amount  of  memory and checking the memory  usage  of  the 
  822.         program by using MDDEBUG.
  823.          
  824.         The syntax for the RM command is:
  825.  
  826.             RM <size in K>
  827.  
  828.         For example:
  829.  
  830.             RM 128
  831.  
  832.         Use  RM 128 to create a 128K memory partition for the next loaded 
  833.         program.  The memory is not reserved until the program is loaded. 
  834.         If there is not enough memory to create the partition when the RM 
  835.         command  is issued,  no error message will be issued.  The  error 
  836.         message  will be issued when the command to load the  program  is 
  837.         executed.
  838.  
  839.         NOTE:  RM and AM commands perform similar functions.  RM lets you 
  840.         specify total size needed. AM specifies additional memory.
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.                                      (11)
  857.  
  858.  
  859.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  860.  
  861.         SBK - Suspend Task in the Background
  862.  
  863.         The  program will run only when it is in the foreground state.  A 
  864.         typical  use for this command is to prevent programs which  write 
  865.         directly  to  the  display  memory  from  interfering  with   the 
  866.         foreground  display.  The foreground display is preserved between 
  867.         foreground to background and back to foreground switches.
  868.  
  869.         XMP - Program Uses Expanded Memory
  870.  
  871.         Use  the  XMP command to indicate that the program  about  to  be 
  872.         loaded will use expanded memory.  With this option, MultiDos Plus 
  873.         will  save the LIM map context at the end of every time slice for 
  874.         the program and restore it when the program is ready to run.  Use 
  875.         of this option has no bearing on whether the program is loaded in 
  876.         expanded or conventional memory.  It only instructs MultiDos Plus 
  877.         that the program will make LIM EMM calls on its own.
  878.  
  879.         XQ - Start Execution of Next Program Immediately After Loading
  880.  
  881.         The  XQ  command  will cause the next  program  loaded  to  start 
  882.         running  immediately after it is loaded.  If this command is  not 
  883.         used, a program will start running only when it is brought to the 
  884.         foreground  for the first time.  If you use the ND  command,  you 
  885.         must use the XQ command before loading the program.
  886.  
  887.         Load Program
  888.         ------------
  889.  
  890.         RU - Load the Specified Program into Memory
  891.  
  892.         The RU command is used to actually load a program into memory and 
  893.         ready  it  for  execution.   The  program  is  loaded  using  the 
  894.         parameters  established  by previously entered commands like  RM, 
  895.         XQ,  ND and DI.  After the program is loaded,  the parameters are 
  896.         reset to their initial default values. A loaded program becomes a 
  897.         task under MultiDos Plus.
  898.  
  899.         The following is the basic syntax of the RU command:
  900.  
  901.             RU <program name> <prog cmd line args>
  902.  
  903.         The  <prog  cmd line args> are the command  line  arguments  that 
  904.         would  normally  be  supplied to a program if  it  were  executed 
  905.         directly from DOS.
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.                                      (12)
  923.  
  924.  
  925.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  926.  
  927.         MultiDos  Plus  does not require you to type RU.  You may load  a 
  928.         program  simply by typing the name of the program as long as  the 
  929.         program name does not conflict with any MultiDos Plus command.
  930.  
  931.         eg. RU PROG ARG1 ( or PROG ARG1 )
  932.  
  933.         If  the name of a program conflicts with a MultiDos Plus  command 
  934.         and the RU is not specified, the MultiDos Plus command definition 
  935.         takes precedence.
  936.  
  937.         The  program name may be any valid DOS path name of a COM  or  an 
  938.         EXE file. If a simple file name is specified, the DOS environment 
  939.         PATH variable is used to locate the program.
  940.  
  941.         Once loaded, the program name is also used for the task name. The 
  942.         first  seven  (7) characters up to the period (.) of  the  simple 
  943.         file name are used for the task name.  If a file with a path name 
  944.         of \ABC\DEFGHIJK.EXE were loaded, the task name would be DEFGHIJ. 
  945.         The  directory specification of \ABC\ is dropped and so is the K. 
  946.         The  .EXE or .COM extension is never included.  If the RU is  not 
  947.         specified, the name is also converted to upper case.
  948.  
  949.         The   standard  input/output  redirection  and   pipes   normally 
  950.         supported  by the DOS COMMAND.COM program are not available  when 
  951.         running under MultiDos Plus.
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.                                      (13)
  989.  
  990.  
  991.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  992.  
  993.         Execution Control Commands
  994.         --------------------------
  995.  
  996.         AB - Abort Task
  997.  
  998.         Abort the named task.  The task is actually aborted the next time 
  999.         it gets scheduled for execution. If the task is suspended for any 
  1000.         reason (waiting for keyboard,  waiting for a semaphore, etc.), it 
  1001.         will be aborted only when it gets out of the suspended state.
  1002.  
  1003.         The syntax for the AB command is:
  1004.  
  1005.             AB <task name>
  1006.  
  1007.         When  MultiDos Plus aborts the task,  the memory reserved for the 
  1008.         program is returned to the free memory pool.
  1009.  
  1010.         CAUTION: If the task has "hooked" into any interrupt vectors, the 
  1011.         consequences  of  leaving interrupt vectors  pointing  to  unused 
  1012.         memory may cause unexpected results.
  1013.  
  1014.         FG - Move Background Task to Foreground
  1015.  
  1016.         Use  the FG command to bring the named task into the  foreground. 
  1017.         The syntax for the FG command is:
  1018.  
  1019.             FG <task name>
  1020.  
  1021.         If  the  task  has  just  been loaded and  is  waiting  to  begin 
  1022.         execution,  it will begin execution as soon as it has control  of 
  1023.         the foreground display.
  1024.  
  1025.         Information  on  possible uses of the FG command is given in  the 
  1026.         sections on Foreground/Background Program Selection and Automatic 
  1027.         Startup in this chapter.
  1028.  
  1029.         GO - Resume Execution of a Task
  1030.  
  1031.         A task which was previously suspended using the SS command can be 
  1032.         restarted at the point where it was suspended. The syntax for the 
  1033.         GO command is:
  1034.  
  1035.             GO <task name>
  1036.  
  1037.         The  task  is removed from the Suspend queue and  placed  on  the 
  1038.         Ready queue.
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.                                      (14)
  1055.  
  1056.  
  1057.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1058.  
  1059.         PR - Set or Display Task Priority
  1060.  
  1061.         Each  task in the system is assigned an execution  priority.  The 
  1062.         priority  determines how often the task is given a slice of  time 
  1063.         by  the task scheduler.  The lower the priority number,  the more 
  1064.         frequently the task will be scheduled.
  1065.  
  1066.         The PR command allows a task priority to be set to a value from 0 
  1067.         to  255.  If no value is specified in the  command,  the  current 
  1068.         priority  of  the  task  is displayed.  If you  do  not  set  any 
  1069.         priority,  loaded  tasks will default to priority 0 or the  level 
  1070.         specified by the /PR command line option.
  1071.  
  1072.         The following is the syntax of the PR command:
  1073.  
  1074.             PR <task name> <priority value>
  1075.  
  1076.         SS - Suspend Task
  1077.  
  1078.         The  execution  of  the specified task is suspended  until  a  GO 
  1079.         command  is issued to reactivate the task.  The syntax for the SS 
  1080.         command is:
  1081.  
  1082.             SS <task name>
  1083.  
  1084.         It  is  important to note that even though a task is  marked  for 
  1085.         suspension,  it may not be  suspended immediately.  Tasks waiting 
  1086.         for  keyboard  input,  semaphores,  events and messages  are  not 
  1087.         suspended  until  their current requests are  satisfied.  A  task 
  1088.         performing  a  DOS function call is not suspended until  the  DOS 
  1089.         call is complete.
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.                                      (15)
  1121.  
  1122.  
  1123.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1124.  
  1125.         Miscellaneous Commands
  1126.         ----------------------
  1127.  
  1128.         ANSI - Activate ANSI.SYS for Task
  1129.  
  1130.         The  ANSI  command activates the  ANSI.SYS  driver  functionality 
  1131.         built into MultiDos Plus for the specified task.  ANSI.SYS can be 
  1132.         enabled or disabled on a per task basis.  The syntax for the ANSI 
  1133.         command is:
  1134.  
  1135.             ANSI <task name>
  1136.  
  1137.         The  <task  name> is the name of the task to  be  activated.  The 
  1138.         default  when a task is loaded is to have ANSI.SYS enabled.  If a 
  1139.         task should not have the ANSI.SYS functionality activated for  it 
  1140.         (for  example,  a  task loaded with the COMM option),  the  NANSI 
  1141.         command can be used to disable this functionality.
  1142.  
  1143.         ECHO - Echo Text
  1144.  
  1145.         Any  text  following the ECHO keyword is echoed to  the  display. 
  1146.         This command may be useful in AUTO.MTX files to display  messages 
  1147.         during a turnkey system startup. The following line:
  1148.  
  1149.             ECHO This is a test
  1150.  
  1151.         will display "This is a test" on the CRT display.
  1152.  
  1153.         The command "ECHO *" will clear the display.
  1154.  
  1155.  
  1156.         EXIT - Terminate MultiDos Plus
  1157.  
  1158.         This  command terminates MultiDos Plus and restores the system to 
  1159.         its original state. All running tasks are immediately terminated. 
  1160.         Caution should be used when using this command as some tasks  may 
  1161.         have  taken  certain interrupts during execution,  and  the  EXIT 
  1162.         command  will  not restore the interrupt vector to  its  original 
  1163.         state.
  1164.  
  1165.         The  EXIT command has no effect if MultiDos Plus is running as  a 
  1166.         DOS SHELL.
  1167.  
  1168.         NANSI - Disable ANSI.SYS
  1169.  
  1170.         Use the NANSI command to disable ANSI.SYS for a task. When a task 
  1171.         is loaded,  the default is to have ANSI.SYS in effect for a task. 
  1172.         The ANSI.SYS functions can be reactivated using the ANSI command. 
  1173.         The syntax for the NANSI command is:
  1174.  
  1175.             NANSI <task name>
  1176.  
  1177.         <task name> is the task name of the task for which ANSI.SYS is to 
  1178.         be disabled.
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.                                      (16)
  1187.  
  1188.  
  1189.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1190.  
  1191.         FOREGROUND/BACKGROUND PROGRAM SELECTION
  1192.  
  1193.         As  described  earlier,  there  is  always  only  one  foreground 
  1194.         program;  and the rest of the programs are in the background. You 
  1195.         can swap programs between foreground and background by doing ALTZ 
  1196.         (pressing  ALT  key and Z key at the same time).  If you do  ALTZ 
  1197.         when  you  have an application program in  the  foreground,  your 
  1198.         foreground program will go to the background;  and MultiDos  Plus 
  1199.         will come to the foreground.
  1200.  
  1201.         If you do ALTZ with MultiDos Plus in the foreground, you will see 
  1202.         the  name of one of your background programs.  At this point  you 
  1203.         will  be  invited  to  either hit a return or  do  another  ALTZ. 
  1204.         Hitting  the return will banish MultiDos Plus to  the  background 
  1205.         and bring the named program to the foreground. Doing another ALTZ 
  1206.         instead of hitting the return will list the next program (if any) 
  1207.         in the background.
  1208.  
  1209.         A program loaded without a background display memory may never be 
  1210.         brought  to  the foreground.  For this reason,  programs  without 
  1211.         display memory will not have their name shown when the ALTZ  task 
  1212.         list is being displayed.
  1213.  
  1214.         Another  method of establishing the foreground program is to  use 
  1215.         the  MultiDos  Plus  FG  command.  This command  can  be  invoked 
  1216.         directly  from the MultiDos Plus command line or another  program 
  1217.         can  issue the command using the API function to invoke  MultiDos 
  1218.         Plus commands from a program.
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.                                      (17)
  1253.  
  1254.  
  1255.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1256.  
  1257.         EXECUTING DOS COMMANDS
  1258.  
  1259.         A set of DOS commands,  known as DOS internal commands, are built 
  1260.         into  the  DOS  command  processor,  COMMAND.COM.  This  includes 
  1261.         commands  to list a directory,  copy files,  delete  files,  etc. 
  1262.         Also, the ability to execute batch files requires COMMAND.COM.
  1263.  
  1264.         MultiDos Plus users who require these features should, therefore, 
  1265.         first  load  and execute COMMAND.COM.  The amount  of  memory  to 
  1266.         reserve  for  the COMMAND task depends on what you intend  to  do 
  1267.         with  the  command  processor.  Reserving  64K  is  adequate  for 
  1268.         executing  internal  commands.  Running batch files which  invoke 
  1269.         other  programs may require you to reserve sufficient memory  for 
  1270.         their  execution  as  well  as  the  memory  needed  to   execute 
  1271.         COMMAND.COM.
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.                                      (18)
  1319.  
  1320.  
  1321.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1322.  
  1323.         AUTOMATIC STARTUP
  1324.  
  1325.         Many  applications  require  startup  with  little  or  no  human 
  1326.         intervention  (a  turnkey  system).  MultiDos Plus  has  all  the 
  1327.         features neccessary to be used in a turnkey system.
  1328.  
  1329.         To  start MultiDos Plus automatically,  modify  the  AUTOEXEC.BAT 
  1330.         file to invoke MULTIDOS.EXE.  NOTE: The command to start MultiDos 
  1331.         Plus should be the very last command in the batch file.
  1332.  
  1333.         Now  create  a  standard ASCII text file with the  MultiDos  Plus 
  1334.         commands  needed to load and begin execution of your  application 
  1335.         programs.  Although the name of the file is not important, if you 
  1336.         name it AUTO.MTX and place it in the current directory,  MultiDos 
  1337.         Plus  will  automatically look for it and  execute  the  commands 
  1338.         placed therein.  If you choose a different file name or place the 
  1339.         file in a different directory,  use the /AUTO command line option 
  1340.         to tell MultiDos Plus where the file is located.
  1341.  
  1342.         Normally,  MultiDos Plus will echo each command it reads from the 
  1343.         AUTO.MTX  file just before it executes the command.  You may  use 
  1344.         the  command line option /NOECHO to suppress the echoing of those 
  1345.         commands.  You  may  also  want to use the  /NOPROMPT  option  to 
  1346.         inhibit the display of the MultiDos Plus command prompt.
  1347.  
  1348.         In  a  turnkey system you may want to disable the  ALTZ  hot  key 
  1349.         facility.  If  your  system operators do not have access  to  the 
  1350.         MultiDos  Plus  command  level,  they will not be able  to  abort 
  1351.         tasks, load other programs, or any other nasty things you may not 
  1352.         want  them to do.  Use the /NALTZ command line option to  disable 
  1353.         the ALTZ facility. The /NALTZ option will disable the ALTZ before 
  1354.         any other operation occurs.
  1355.  
  1356.         Since  you will probably want to disable the ALTZ  facility,  you 
  1357.         will need an alternative method of starting your programs.  Also, 
  1358.         you  will  probably want one specific task to  become  the  first 
  1359.         foreground  task.  The  XQ command will force programs  to  begin 
  1360.         execution without being brought to the foreground. The FG command 
  1361.         should  be  the last command in the file and will  establish  the 
  1362.         desired foreground program.
  1363.  
  1364.         Before each program is loaded,  be sure to specify the XQ command 
  1365.         so  that  the  program  will begin  execution  immediately  after 
  1366.         loading.  This  way  the  program  need not  be  brought  to  the 
  1367.         foreground to initiate its execution.  This command would also be 
  1368.         needed to start any programs which have no display.
  1369.  
  1370.         The  very  last  command in the AUTO.MTX file should  be  the  FG 
  1371.         command  to start the foreground task.  The foreground task  need 
  1372.         not  be loaded with the XQ command option.  The FG  command  will 
  1373.         cause the task to begin execution.
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.                                      (19)
  1385.  
  1386.  
  1387.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1388.  
  1389.         RUNNING MULTIDOS PLUS AS A DOS SHELL
  1390.  
  1391.         In  many  turnkey  systems  there  may be no  need  for  the  DOS 
  1392.         COMMAND.COM  software.  If  this  is the  case  in  your  system, 
  1393.         MultiDos Plus can be executed as the DOS SHELL.
  1394.  
  1395.         If  you want to run MultiDos as a DOS SHELL,  enter the following 
  1396.         line in your system's CONFIG.SYS file:
  1397.  
  1398.             SHELL=MULTIDOS <options>
  1399.  
  1400.         This  assumes that the MULTIDOS.EXE file is located in  the  root 
  1401.         directory  of  the  boot  drive.  The <options> are  any  of  the 
  1402.         MultiDos  Plus command line options which may be needed for  your 
  1403.         configuration.
  1404.  
  1405.         Because  SHELL programs are not given  an  environment,  MultiDos 
  1406.         Plus will create an environment with only a single null string to 
  1407.         pass on to loaded programs.
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.                                      (20)
  1451.  
  1452.  
  1453.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1454.  
  1455.         CHAPTER III
  1456.         -----------
  1457.  
  1458.  
  1459.         USING MDDEBUG
  1460.         -------------
  1461.  
  1462.         Included  with  the  MultiDos Plus software is  a  program  named 
  1463.         MDDEBUG  which  may  be used to observe the state of  the  system 
  1464.         during  execution.  For  example,  the  execution  context  of  a 
  1465.         program,  its  PSP,  environment  and  other  parameters  can  be 
  1466.         examined.  MDDEBUG will also allow you to display memory,  system 
  1467.         variable contents,  check resource ownership,  and list the tasks 
  1468.         in the system. The following describes how to execute MDDEBUG and 
  1469.         its  various  commands.  Used  in conjunction  with  an  hardware 
  1470.         emulation  debug facility,  MDDEBUG is invaluable for debuging  a 
  1471.         multitasking application. If you are using a system with a "dumb" 
  1472.         terminal connected,  you can use the COMM command to run  MDDEBUG 
  1473.         from the terminal if you have a communication driver installed as 
  1474.         described  in  the Software Interface for Terminal  Communication 
  1475.         section in Chapter V.
  1476.  
  1477.         Note  that  MDDEBUG makes reference to tasks  and  not  programs. 
  1478.         Although a program loaded under MultiDos Plus becomes a task,  it 
  1479.         is possible for a program to contain more than one task.  MDDEBUG 
  1480.         will  show all the tasks runing under MultiDos Plus.  See the API 
  1481.         functions  in  Chapter  IV  for  more  information  on   creating 
  1482.         "internal" tasks or "threads".
  1483.  
  1484.         To run MDDEBUG, just type:
  1485.  
  1486.                 MDDEBUG
  1487.  
  1488.         at the MultiDos Plus command prompt. If your system is configured 
  1489.         with LIM 4.0 expanded memory,  use the LC command to ensure  that 
  1490.         it   is  loaded  into  conventional  memory.   It  must  run   in 
  1491.         conventional memory in order to access data in programs loaded in 
  1492.         LIM memory.
  1493.  
  1494.         Use ALTZ to select and run MDDEBUG.
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.                                      (21)
  1517.  
  1518.  
  1519.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1520.  
  1521.         You  will  be  presented with a signon message  and  the  MDDEBUG 
  1522.         prompt which looks like:
  1523.  
  1524.              MDDEBUG>
  1525.  
  1526.         You may now enter one of the following single character commands. 
  1527.         Enter a ? to get on-line help.
  1528.  
  1529.         (C)heck Message Queue
  1530.         (D)ump Memory
  1531.         (E)nvironment of a Task
  1532.         (F)ree Memory for Task
  1533.         (H)andles and File Names for a Task
  1534.         (I)ssue a Message to a Message Queue
  1535.         (L)ist Task Names and Numbers
  1536.         (M)ultiDos Command
  1537.         (P)SP Information of a Task
  1538.         (Q)uit
  1539.         (R)esource Semaphore Owners and Requestors
  1540.         (S)ystem Block
  1541.         (T)ask Status
  1542.         (X)panded Memory Information
  1543.  
  1544.         When  a  command  is entered,  the operator is prompted  for  any 
  1545.         additional  parameters  required  to  process  the  command.  The 
  1546.         command is executed, and the MDDEBUG prompt is again displayed.
  1547.  
  1548.         The remainder of this chapter describes the commands in detail.
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.                                      (22)
  1583.  
  1584.  
  1585.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1586.  
  1587.         (C)heck Message Queue
  1588.  
  1589.         The "C" command is used to check the contents of a message queue. 
  1590.         When  you press the "C" key,  you will be asked to enter a  queue 
  1591.         number.  The number must be a decimal value between 0 and 63. The 
  1592.         status  of the message queue is then displayed.  Tasks waiting on 
  1593.         the queue,  if any, are listed. If any messages are on the queue, 
  1594.         the  contents  of the messages are displayed.  All  messages  are 
  1595.         displayed in both hexadecimal and ASCII.
  1596.  
  1597.  
  1598.         (D)ump Memory
  1599.  
  1600.         The "D" command is used to display the contents of memory in  the 
  1601.         system. When you press the "D" key, MDDEBUG will ask for a memory 
  1602.         address  to  display.  If the address falls in the  LIM  expanded 
  1603.         memory  page  frame,  the number of the task whose memory  is  of 
  1604.         interest  is requested.  Use the "L" command to obtain a list  of 
  1605.         tasks  and  their  numbers.  MDDEBUG will make sure the  task  is 
  1606.         mapped in during the display process.
  1607.  
  1608.         When the address of the memory to be displayed is  requested,  it 
  1609.         must be entered in the form SEGMENT:OFFSET and the values entered 
  1610.         must be hexadecimal.
  1611.  
  1612.         Memory is displayed in 32-byte chunks.  Each line displayed shows 
  1613.         16  bytes:  first  in  hexadecimal format and then  in  printable 
  1614.         ASCII.  If  a  byte is not a printable  ASCII  character,  it  is 
  1615.         displayed  as a period (.).  After the 32 bytes are displayed,  a 
  1616.         prompt is issued for another memory address.  If a blank line  is 
  1617.         entered,  the  next  32  bytes are displayed.  If an  address  is 
  1618.         entered, 32 bytes are displayed starting with the new address.
  1619.  
  1620.  
  1621.         (E)nvironment of a Task
  1622.  
  1623.         The "E" command is used when you need to display the  environment 
  1624.         of  a task.  When you press the "E" key,  the task number will be 
  1625.         requested.  Use  the  "L" command to obtain a list of  tasks  and 
  1626.         their  numbers.  Enter  the number of the task in which  you  are 
  1627.         interested.  The individual environment strings for the task will 
  1628.         then be displayed.  The path name of the task's program file will 
  1629.         be displayed last.
  1630.  
  1631.         (F)ree Memory for Task
  1632.  
  1633.         The  "F"  command  is  used  to  display  the  memory  allocation 
  1634.         information  of  a task.  When you press the "F"  key,  the  task 
  1635.         number will be requested. Use the "L" command to obtain a list of 
  1636.         tasks  and their numbers.  Both the task's available  and  in-use 
  1637.         memory is displayed.  The starting paragraph of each memory block 
  1638.         and  the size of the block are shown.  The starting paragraph  is 
  1639.         displayed  in  hexadecimal,  and the block size is  displayed  in 
  1640.         decimal. The size is the number of bytes (not paragraphs).
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.                                      (23)
  1649.  
  1650.  
  1651.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1652.  
  1653.         (H)andles and File Names for a Task
  1654.  
  1655.         The  "H" command is used to display the file handles in use by  a 
  1656.         task  and the name of the file associated with the  handle.  When 
  1657.         you press the "F" key, you will be asked to provide the number of 
  1658.         the task. Use the "L" command to obtain a list of tasks and their 
  1659.         numbers.  The task name and the maximum number of files the  task 
  1660.         may have open is displayed. The file handle numbers are displayed 
  1661.         next,  one handle to a line.  Following each handle number is the 
  1662.         DOS  file name associated with the handle.  Only the name of  the 
  1663.         file  is  displayed.  The directory and disk of the file are  not 
  1664.         provided.
  1665.  
  1666.  
  1667.         (I)ssue a Message to a Message Queue
  1668.  
  1669.         The  "I"  command is used to place a text message on  a  selected 
  1670.         message queue.  When you press the "I" key,  you will be prompted 
  1671.         for  the queue number and then for the text of the  message.  The 
  1672.         message  will be placed on the specified queue.  The  message  is 
  1673.         limited to text characters entered from the keyboard.
  1674.  
  1675.  
  1676.         (L)ist Task Names and Numbers
  1677.  
  1678.         The  "L"  command  is  used to request a list of  the  names  and 
  1679.         numbers  of all the tasks in the system.  When you press the  "L" 
  1680.         key,  all the tasks (and their associated numbers) in the  system 
  1681.         are listed, one per line. Each task name is preceeded by a number 
  1682.         which is its task number.  The task number is used to reference a 
  1683.         specific  task in many of the other MDDEBUG  commands.  Following 
  1684.         each task name is a number which is the priority of the task.
  1685.  
  1686.  
  1687.         (M)ultiDos Command
  1688.  
  1689.         The "M" command is used to send MultiDos Plus an Operator Command 
  1690.         from  MDDEBUG.  When you press the "M" key,  you will be asked to 
  1691.         enter  a  command string.  Up to 80 characters  may  be  entered, 
  1692.         terminated  by a carriage return.  The command string is sent  to 
  1693.         the  MultiDos Plus command interpreter,  and the string  "Command 
  1694.         sent"  is displayed acknowledging that the command was sent.  The 
  1695.         command  may  be  any valid  MultiDos  Plus  command.  Any  error 
  1696.         messages  are  displayed on the foreground display.  See the  API 
  1697.         function code 15 (Execute a MultiDos Plus Command) in Chapter  IV 
  1698.         for  more  information  on the effects of sending  MultiDos  Plus 
  1699.         commands from a task.
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.                                      (24)
  1715.  
  1716.  
  1717.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1718.  
  1719.         (P)SP Information of a Task
  1720.  
  1721.         The  "P"  command is used to display information  from  a  task's 
  1722.         Program Segment Prefix (PSP). When you press the "P" key, you are 
  1723.         asked for a task number.  Use the "L" command to obtain a list of 
  1724.         tasks  and their numbers.  Information contained in the  selected 
  1725.         task's PSP is displayed.  For more information on the contents of 
  1726.         the  displayed  fields  refer  to your  DOS  Technical  Referance 
  1727.         manual.
  1728.  
  1729.  
  1730.         (Q)uit
  1731.  
  1732.         The  "Q" command is used to terminate execution of MDDEBUG.  When 
  1733.         you press the "Q" key, execution is terminated immediately.
  1734.  
  1735.  
  1736.         (R)esource Semaphore Owners and Requestors
  1737.  
  1738.         The  "R"  command is used to display a snapshot of  the  MultiDos 
  1739.         Plus  Resource  Semaphores.  When  you press  the  "R"  key,  the 
  1740.         Resource  Semaphore  number,  current  owner task  name  and  any 
  1741.         requesting  task's  names  are  displayed for  all  the  Resource 
  1742.         Semaphores having any activity.
  1743.  
  1744.  
  1745.         (S)ystem Block
  1746.  
  1747.         The  "S" command is used to display the contents of the  MultiDos 
  1748.         Plus System Block data structure. When you press the "S" key, the 
  1749.         contents  of the System Block will be displayed.  See the section 
  1750.         on Useful System Data Structures in Chapter IV for a  description 
  1751.         of the fields in the System Block.
  1752.  
  1753.  
  1754.         (T)ask Status
  1755.  
  1756.         The  "T"  command  is useful for obtaining  information  about  a 
  1757.         running task. When you press the "T" key, you will be asked for a 
  1758.         task  number.  Use  the  "L" command to obtain  a  list  of  task 
  1759.         numbers.  Once  you enter the task number,  the information about 
  1760.         the task will be displayed.  The following describes the  meaning 
  1761.         of the displayed information:
  1762.  
  1763.         The  Task  Name is the seven (7) character name of  the  selected 
  1764.         task.  Following  the  name is the priority of the task  and  the 
  1765.         ANSI.SYS emulation state. If ANSI.SYS emulation is turned off for 
  1766.         the task, the state will be 0. Otherwise it will be non-zero.
  1767.  
  1768.         The  next  line  displays the SS and SP registers  for  the  task 
  1769.         followed  on  the  next  line  by the  remainder  of  the  task's 
  1770.         registers.
  1771.  
  1772.         The  environment  segment  from the task's PSP  is  displayed  in 
  1773.         hexadecimal  followed  by the communications port number  of  the 
  1774.         task.  If the task is not communicating with an RS-232  terminal, 
  1775.         the port number will be zero.
  1776.  
  1777.  
  1778.  
  1779.  
  1780.                                      (25)
  1781.  
  1782.  
  1783.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1784.  
  1785.         Twelve fields from the task's TCB are displayed,  four to a line. 
  1786.         They are CURIRQ,  DISMEM, TOPMEM, TSKSEG, EMSPTR, EMMPRG, EMMHND, 
  1787.         ALTMAP,  PARTCB,  TSKPID,  DISTYP,  and  ADDR68.  All values  are 
  1788.         displayed in hexadecimal.
  1789.  
  1790.              Field      Description
  1791.  
  1792.              CURIRQ     value set for task by the IRQ command
  1793.              DISMEM     display memory segment
  1794.              TOPMEM     tasks top of memory in K
  1795.              TSKSEG     PSP segment for the task
  1796.              EMSPTR     segment of LIM map
  1797.              EMMPRG     task uses LIM flag
  1798.              EMMHND     LIM handle for task
  1799.              ALTMAP     LIM alternate map set for task
  1800.              PARTCB     parent tasks TCB offset
  1801.              TSKPID     current DOS process ID
  1802.              DISTYP     0 = MDA, 1 = CGA
  1803.              ADDR68     base i/o address of video controller
  1804.  
  1805.         The next line displays the current display mode for the task, the 
  1806.         number of display columns, and the length of the display memory.
  1807.  
  1808.         The  following line contains the current cursor positions for the 
  1809.         four  display pages (if MDA,  only the first position is  valid), 
  1810.         and  the next line displays the current active display  page  and 
  1811.         the  current  cursor mode.  The MDBIO10 driver only updates  this 
  1812.         information for background tasks. The foreground task information 
  1813.         is kept in the low memory BIOS data area.
  1814.  
  1815.  
  1816.         (X)panded Memory Information
  1817.  
  1818.         The  "X"  command  is  used to  display  information  about  your 
  1819.         system's  expanded memory.  When you press the "X" key,  the  raw 
  1820.         page  size,  number of alternate register sets,  the context save 
  1821.         area  size,  and  the  number  of available  16K  EMS  pages  are 
  1822.         displayed.  Refer  to  your LIM 4.0 driver  specification  for  a 
  1823.         complete  description of these values.  If no expanded memory  is 
  1824.         configured  in  your  system,  the message  "No  expanded  memory 
  1825.         present" will be displayed.
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.                                      (26)
  1847.  
  1848.  
  1849.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1850.  
  1851.         CHAPTER IV
  1852.         ----------
  1853.  
  1854.         THE APPLICATION PROGRAM INTERFACE (API)
  1855.         ---------------------------------------
  1856.  
  1857.         Programs  can  interact  with  each other or  control  their  own 
  1858.         execution by means of calls to the Application Program  Interface 
  1859.         (API).  This is done through the software interrupt 15 (INT 15H). 
  1860.         A  program  must  load the function code of the  function  to  be 
  1861.         performed into the AH register and any required parameters in the 
  1862.         proper  registers  and  execute  an INT  15H  instruction.  If  a 
  1863.         function code not recognized by MultiDos Plus is used in register 
  1864.         AH,  control  is passed to the interrupt handler  present  before 
  1865.         MultiDos Plus was loaded.
  1866.  
  1867.         NOTE: No registers are destroyed unless specifically noted.
  1868.  
  1869.         This  chapter  has  been divided into  four  sections:  Execution 
  1870.         Control  Functions,   Resource  Control   Functions,   Inter-Task 
  1871.         Messaging  Functions,  and Event Trigger Functions.  The function 
  1872.         descriptions  in  each  section are organized  in  function  code 
  1873.         order.  The  following  tables lists the function codes for  each 
  1874.         section. 
  1875.  
  1876.         Execution Control Functions
  1877.  
  1878.                  Function Code   Definition
  1879.                         0       give up time slice
  1880.                         3       suspend task for interval
  1881.                         7       spawn internal task
  1882.                         8       terminate internal task
  1883.                         9       change priority
  1884.                         10      change time slice interval
  1885.                         11      force display output to real video memory
  1886.                         12      restore old video memory
  1887.                         13      turn off time slicing
  1888.                         14      turn on time slicing
  1889.                         15      execute a MultiDos Plus command
  1890.                         17      turn off ALTZ
  1891.                         18      turn on ALTZ
  1892.                         19      return TCB address
  1893.                         20      return foreground/background flag
  1894.                         21      return pointer to System Block
  1895.                         22      initialize ADOS
  1896.                         23      map interrupt request
  1897.                         24      unmap interrupt request
  1898.                         25      unmap all interrupt requests
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.                                      (27)
  1913.  
  1914.  
  1915.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1916.  
  1917.         Resource Control Functions
  1918.  
  1919.                 Function Code    Definition
  1920.                         1       get resource semaphore
  1921.                         2       release resource semaphore
  1922.                         16      test a resource semaphore
  1923.                         26      map semaphore name to number
  1924.                         27      get resource semaphore by name
  1925.                         28      release resource semaphore by name
  1926.                         29      check if resource semaphore available by name
  1927.  
  1928.         Inter-Task Messaging Functions
  1929.  
  1930.                 Function Code    Definition 
  1931.  
  1932.                         4       send message
  1933.                         5       check queue for a message
  1934.                         6       get message
  1935.  
  1936.          Event Trigger Functions
  1937.  
  1938.                 Function Code    Definition 
  1939.  
  1940.                         30      event semaphore functions
  1941.                         30-0    clear event counter
  1942.                         30-1    signal event
  1943.                         30-2    wait for event
  1944.  
  1945.         NOTE: Most compiler systems available for DOS have a facility for 
  1946.         invoking software interrupts.  See the technical reference manual 
  1947.         of your particular compiler for details.
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.                                      (28)
  1979.  
  1980.  
  1981.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  1982.  
  1983.         EXECUTION CONTROL FUNCTIONS
  1984.  
  1985.         The  Execution  Control Functions are provided to  give  tasks  a 
  1986.         means of controlling various aspects of execution.  Functions are 
  1987.         provided for a task to control its own execution,  to examine and 
  1988.         alter  system  wide parameters,  and to control the execution  of 
  1989.         other tasks.  Several of the functions defined here must only  be 
  1990.         used by MultiDos Plus. They are only listed for completeness.
  1991.  
  1992.  
  1993.  
  1994.         Give Up Time Slice
  1995.  
  1996.         Function Code = 0
  1997.  
  1998.         Entry:
  1999.              AH = function code
  2000.  
  2001.         The  task making this call wishes to give up its time slice.  The 
  2002.         next ready task is given the remainder of the time slice.
  2003.  
  2004.         Tasks  which are performing certain types of timing loops  should 
  2005.         use  this function to yield processor time to other tasks in  the 
  2006.         system.
  2007.  
  2008.         If  the /PR command line option was specified when MultiDos  Plus 
  2009.         was started,  and the highest priority task in the system  issues 
  2010.         this  function,  and there are no other tasks of equal or greater 
  2011.         priority, control will return immediately to this task.
  2012.  
  2013.  
  2014.         Suspend Task for Interval
  2015.  
  2016.         Function Code = 3
  2017.  
  2018.         Entry:
  2019.              AH = function code
  2020.              DX = number of time ticks to suspend
  2021.  
  2022.         The  task making this call is suspended for the specified  number 
  2023.         of time ticks.  A time tick is the basic time-slice interval.  Be 
  2024.         aware  that this value can be changed by using function  code  10 
  2025.         (Change Time Slice Interval).
  2026.  
  2027.         This  function  should  be  used by tasks  which  want  to  delay 
  2028.         execution  for a specific period of time.  The normal practice of 
  2029.         executing  a  loop  to maintain timing is not  recommended  in  a 
  2030.         multitasking  environment.  This technique will  waste  processor 
  2031.         time which can be productively used by other tasks.
  2032.  
  2033.         If  the  /PR option was invoked,  this function can provide  very 
  2034.         accurate execution timing for high priority tasks.  High priority 
  2035.         tasks  should use this function to yield processor time to  lower 
  2036.         priority tasks when they no longer need it.
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.                                      (29)
  2045.  
  2046.  
  2047.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2048.  
  2049.         Spawn Internal Task
  2050.  
  2051.         Function Code = 7
  2052.  
  2053.         Entry:
  2054.              AH = function code
  2055.              BX = CS register of new task
  2056.              CX = IP register of new task
  2057.              DX = stack size for new task in paragraphs
  2058.  
  2059.         Exit: 
  2060.              AH = 0 if no error
  2061.                   1 if no free task control blocks
  2062.                   2 if no free memory for the new task's stack
  2063.  
  2064.         A new task,  called an internal task,  is created and will  start 
  2065.         executing at the specified CS:IP. Control is returned immediately 
  2066.         to  the  calling  (parent) task which  continues  execution.  The 
  2067.         memory  for  the stack,  specified in DX,  is obtained  from  the 
  2068.         parent task.  The parent task must,  therefore,  have  sufficient 
  2069.         free memory to start an internal task.
  2070.  
  2071.         See  the  section on Inside MultiDos Plus in Chapter V  for  more 
  2072.         details on the operation of internal tasks.
  2073.  
  2074.  
  2075.         Terminate Execution of an Internal Task
  2076.         Function Code = 8
  2077.  
  2078.         Entry:
  2079.              AH = function code
  2080.  
  2081.         An  internal  task  terminates itself by invoking  this  function 
  2082.         call.  Its stack space (originally obtained from its parent task) 
  2083.         is returned to the free memory pool of the parent task.
  2084.  
  2085.         It is important that an internal task terminate itself using this 
  2086.         function and not one of the DOS termination functions.
  2087.  
  2088.  
  2089.         Change Priority
  2090.         Function Code = 9
  2091.  
  2092.         Entry:
  2093.         AH = function code
  2094.         AL = new priority
  2095.  
  2096.         Change the task priority. Any value between 0 and 255 is allowed.
  2097.  
  2098.         The  meaning  of the priority depends on whether or not  the  /PR 
  2099.         command line option was specified when MultiDos Plus was started. 
  2100.         See  the  /PR  command  line  option  in  Chapter  II  for   more 
  2101.         information.  The  Inside MultiDos Plus section in Chapter V also 
  2102.         has more information on task priority.
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.                                      (30)
  2111.  
  2112.  
  2113.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2114.  
  2115.         Change Time Slice Interval
  2116.         Function Code = 10
  2117.  
  2118.         Entry:
  2119.              AH =       function code
  2120.              AL =       00H = 55 milliseconds (default)
  2121.                         80H = 27.5 milliseconds
  2122.                         40H = 13.75 milliseconds
  2123.                         20H = 6.88 milliseconds
  2124.                         10H = 3.44 milliseconds
  2125.                         08H = 1.22 milliseconds
  2126.  
  2127.         This   function  changes  the  length  of  the  basic  time-slice 
  2128.         interval.   Unless  specifically  stated,  MultiDos  Plus  begins 
  2129.         execution with a default time-slice interval of 55  milliseconds. 
  2130.         This  is  the  normal  interval programmed  into  the  timer  for 
  2131.         interrupt  8.  MultiDos Plus uses interrupt 8 to preempt  running 
  2132.         tasks.
  2133.  
  2134.         Although  MultiDos  Plus will change the interrupt  interval  for 
  2135.         interrupt  8,  a  count of the number of times the interrupt  has 
  2136.         occured is maintained and after 55 milliseconds has elapsed,  the 
  2137.         interrupt 8 handler,  which was present before MultiDos Plus,  is 
  2138.         executed.  This  preserves  the BIOS time-of-day  and  any  other 
  2139.         timing required by your PC BIOS and TSR's.
  2140.  
  2141.         When  MultiDos Plus terminates execution,  the timer is reset  to 
  2142.         its original 55 millisecond interval.
  2143.  
  2144.         Force Display Output to Real Video Memory
  2145.         Function Code = 11
  2146.  
  2147.         Entry:
  2148.                 AH = function code
  2149.  
  2150.         The  pointer to the task display memory is forced to point to the 
  2151.         real  hardware display memory.  The old pointer is saved for  the 
  2152.         task  and  may be restored using function code  12  (Restore  Old 
  2153.         Video Display Memory).
  2154.  
  2155.         This function is useful if a task wants to force a message to the 
  2156.         CRT display regardless of its foreground/background state.
  2157.  
  2158.         In order for this function to work properly,  the invoking task's 
  2159.         display  mode  must  be the same as the foreground  task's  mode. 
  2160.         Also,  the  text  is  displayed at the  current  cursor  position 
  2161.         defined  for  the issuing task which may not be the same  as  the 
  2162.         cursor position of the foreground task.
  2163.  
  2164.         If a task issues this function and writes to the display when  it 
  2165.         is  a  background task,  the displayed data will be saved to  the 
  2166.         foreground task's background virtual display if it is switched to 
  2167.         the background.
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.                                      (31)
  2177.  
  2178.  
  2179.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2180.  
  2181.         Restore Old Video Display Memory
  2182.  
  2183.         Function Code = 12
  2184.  
  2185.         Entry:
  2186.                 AH = function code
  2187.  
  2188.         The  old video display memory pointer saved by function  code  11 
  2189.         (Force Display Output to Real Video Memory) is restored.
  2190.  
  2191.         NOTE:  Function  codes 11 and 12 are useful if a background  task 
  2192.         wants to display a message in the foreground display.
  2193.  
  2194.         This  function  must not be called unless a function code 11  has 
  2195.         been executed by the task.
  2196.  
  2197.         The  execution  of function codes 11 and 12 does not  affect  the 
  2198.         display of a foreground task.
  2199.  
  2200.  
  2201.         Disable Multitasking
  2202.  
  2203.         Function Code = 13
  2204.  
  2205.         Entry:
  2206.                 AH = function code
  2207.  
  2208.         When  the timer interrupt signals the end of the time  slice  for 
  2209.         this  task,  MultiDos Plus gives the next time slice to the  same 
  2210.         task.  This effectively turns off the time slicing. The task will 
  2211.         continue  to  receive all the CPU time until a function  code  14 
  2212.         (Enable Multitasking) is executed.
  2213.  
  2214.         This  function,   which  disables  multitasking,  is  useful  for 
  2215.         processing  time-critical  events.  It may also be  useful  while 
  2216.         executing  regions of nonreentrant code shared by multiple tasks. 
  2217.         A  critical region of code would be bracketed by a function  code 
  2218.         13 and a function code 14 which enables multitasking.
  2219.  
  2220.         Hardware  interrupts  remain enabled even  when  multitasking  is 
  2221.         turned off.
  2222.  
  2223.  
  2224.         Enable Multitasking
  2225.  
  2226.         Function Code = 14
  2227.  
  2228.         Entry:
  2229.                 AH = function code
  2230.  
  2231.         This  function  reverses the effect of function code 13  (Disable 
  2232.         Multitasking).  If function code 13 is issued and is not followed 
  2233.         by function code 14, no other task would receive time slices.
  2234.  
  2235.         See  function  code  13 for more  information  on  disabling  and 
  2236.         enabling multitasking.
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.                                      (32)
  2243.  
  2244.  
  2245.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2246.  
  2247.         Execute a MultiDos Plus Command
  2248.  
  2249.         Function Code = 15
  2250.  
  2251.         Entry:
  2252.                 AH = function code
  2253.                 DS:BX = pointer to null terminated command string
  2254.  
  2255.         The  string  pointed to by DS:BX is executed as a  MultiDos  Plus 
  2256.         command  as if the command had been typed in at the MultiDos Plus 
  2257.         prompt.  The  string  must  be  terminated  with  an  ASCII  null 
  2258.         character and must not include a carriage return or line feed  at 
  2259.         the  end.  Any lower case characters in the command are converted 
  2260.         to  upper  case,  up to the first space,  before the  command  is 
  2261.         executed.  The  converted  characters are placed  back  into  the 
  2262.         command  buffer.  You can use this call to start other  programs, 
  2263.         suspend programs, etc.
  2264.  
  2265.         When  a  task invokes this function,  the task is  suspended  and 
  2266.         placed  in  a  First-In-First-Out  (FIFO)  queue.  The  queue  is 
  2267.         serviced by MultiDos Plus periodically.  When MultiDos Plus finds 
  2268.         a  request to execute a command,  the command is executed  before 
  2269.         the  task is allowed to resume execution.  If several tasks issue 
  2270.         requests  at the same time,  the requests are serviced in a  FIFO 
  2271.         order.
  2272.  
  2273.  
  2274.  
  2275.         Turn Off ALTZ Toggle
  2276.  
  2277.         Function Code = 17
  2278.  
  2279.         Entry:
  2280.                 AH = function code
  2281.          
  2282.         This  function disables the ALTZ foreground/background  selection 
  2283.         key. Once this function has been issued, pressing the ALT and the 
  2284.         Z key together will have no affect on MultiDos Plus. The only way 
  2285.         to switch between foreground and background would be to issue  an 
  2286.         FG  command  to  MultiDos  Plus using INT 15H  function  code  15 
  2287.         (Execute a MultiDos Plus Command).
  2288.  
  2289.  
  2290.         Turn On ALTZ Toggle (default)
  2291.  
  2292.         Function Code = 18
  2293.  
  2294.         Entry:
  2295.                 AH = function code
  2296.  
  2297.         This  function enables the ALTZ  foreground/background  selection 
  2298.         key.  This  is  the default mode when MultiDos Plus first  begins 
  2299.         execution unless the command line option /NALTZ was specified. If 
  2300.         the ALTZ hot key was disabled, this function will reenable it.
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.                                      (33)
  2309.  
  2310.  
  2311.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2312.  
  2313.         Get Task Control Block Address
  2314.         Function Code = 19
  2315.  
  2316.         Entry:
  2317.               AH = function code
  2318.  
  2319.         Exit:
  2320.                 AX = offset of the task control block
  2321.                 BX = segment of the task control block
  2322.  
  2323.         The  segment  and offset of the Task Control Block (TCB)  of  the 
  2324.         calling  task  is  returned.  A TCB is  a  structure  created  by 
  2325.         MultiDos  Plus  for each task in the system.  See the section  on 
  2326.         Useful  System Data Structures in Chapter V for more  information 
  2327.         on the contents of the TCB.
  2328.  
  2329.         All  TCBs reside in the same data segment which can be  found  in 
  2330.         the first field of the System Block and is labeled as the segment 
  2331.         of the System Control Block.
  2332.  
  2333.  
  2334.         MultiDos Plus Foreground/Background Flag
  2335.         Function Code = 20
  2336.  
  2337.         Entry:
  2338.              AH = function code
  2339.  
  2340.         Exit:
  2341.                 AX =    0 if MultiDos Plus is the background task
  2342.                         1 if MultiDos Plus is the foreground task
  2343.  
  2344.         Using this function, a task can check to see if the MultiDos Plus 
  2345.         command task is in the foreground or background.
  2346.  
  2347.         A task can check if it is the foreground task by testing the flag 
  2348.         at offset 72 in its TCB.   If the word at that location is binary 
  2349.         zero,  the  task  is in the background.  The TCB of  the  current 
  2350.         foreground  task can be located using the pointer at offset 22 in 
  2351.         the System Block.
  2352.  
  2353.  
  2354.         Get System Block Pointer
  2355.         Function Code = 21
  2356.  
  2357.         Entry:
  2358.                 AH = function code
  2359.  
  2360.         Exit:
  2361.                 AX = offset of the System Block
  2362.                 BX = segment of the System Block
  2363.  
  2364.         This  function returns a pointer to the System  Block  structure. 
  2365.         See the section on Useful System Data Structures in Chapter V for 
  2366.         more  details on the position of data in the System  Block.  This 
  2367.         structure   contains  information  which  may  be  useful  to  an 
  2368.         application.
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.                                      (34)
  2375.  
  2376.  
  2377.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2378.  
  2379.         MultiDos Plus Initialization
  2380.         Function Code = 22
  2381.  
  2382.         Entry:
  2383.                 AH = function code
  2384.  
  2385.         This function is used by MultiDos Plus during initialization  and 
  2386.         should  not be invoked by any other task.  It is documented  here 
  2387.         for  the  sake  of  completeness.  Any attempt to use  it  by  an 
  2388.         application program will cause unpredictable, erratic results.
  2389.  
  2390.  
  2391.  
  2392.         Map IRQ
  2393.         Function Code = 23
  2394.  
  2395.         Entry:
  2396.                 AH = function code
  2397.                 AL = interrupt request number to map (1 - 15)
  2398.                 BX = offset of Task Control Block (TCB) to associate 
  2399.                      to interrupt
  2400.  
  2401.         Exit:
  2402.                 AX = 0 if successful, not 0 if invalid value in AL
  2403.  
  2404.         The LIM map of the task identified by the TCB is associated  with 
  2405.         the   hardware  Interrupt  ReQuest  level  specified  in  the  AL 
  2406.         register.   The  value  of  the  AL  register  is  determined  by 
  2407.         subtracting 8 from the interrupt number.  For example, a value of 
  2408.         1  corresponds  to  interrupt 9 which is  normally  the  keyboard 
  2409.         hardware  interrupt.  Mapping interrupt 8 (IRQ 0) is not  allowed 
  2410.         and  returns a nonzero value in AX.  Values in register AL  which 
  2411.         are  greater  than 7 are determined by subtracting 68H  from  the 
  2412.         interrupt  number.  For  example,  a value of  8  corresponds  to 
  2413.         interrupt 70H which is IRQ 8 on the second PIC of an AT.
  2414.  
  2415.         A task may only be associated with one IRQ at a time.  If the IRQ 
  2416.         is  changed  for a task,  be sure to use function code 24  (Unmap 
  2417.         IRQ) to disassociate an existing IRQ relationship.
  2418.  
  2419.         This  function  is normally issued by the MultiDos  Plus  command 
  2420.         task when a program is loaded with an IRQ command in effect.
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.                                      (35)
  2441.  
  2442.  
  2443.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2444.  
  2445.         Unmap IRQ
  2446.         Function Code = 24
  2447.  
  2448.         Entry:
  2449.                 AH = function code
  2450.                 AL = interrupt request number to unmap (1 - 15)
  2451.  
  2452.         Exit:
  2453.                 AX = 0 if successful, not 0 if invalid value in AL
  2454.  
  2455.         The Task Control Block (TCB) is disassociated from the  specified 
  2456.         interrupt   request  level.   The  association  must  have   been 
  2457.         previously established using function code 23 (Map IRQ).
  2458.  
  2459.         Unpredictable results may occur if no relationship exists for the 
  2460.         interrupt  specified in the AL register when function code 24  is 
  2461.         invoked.
  2462.  
  2463.  
  2464.  
  2465.         Unmap all IRQ'S
  2466.         Function Code = 25
  2467.  
  2468.         Entry:
  2469.                 AH = function code
  2470.  
  2471.         Exit:
  2472.                 AX = destroyed
  2473.  
  2474.         This  function  is  used  by MultiDos Plus  to  restore  all  the 
  2475.         hardware  interrupt  vectors to the values present when  MultiDos 
  2476.         Plus first began execution.
  2477.  
  2478.         WARNING: This function is for MultiDos Plus internal use only.
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.                                      (36)
  2507.  
  2508.  
  2509.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2510.  
  2511.         RESOURCE CONTROL FUNCTIONS
  2512.         --------------------------
  2513.  
  2514.         Tasks running under MultiDos Plus can synchronize their execution 
  2515.         and also share common resources by using "semaphores". Semaphores 
  2516.         are also referred to in this document as "resource semaphores".
  2517.  
  2518.         Thirty-one  semaphores  numbered 1 through 31 are  available  for 
  2519.         MultiDos  Plus applications.  These semaphores are  created  when 
  2520.         MultiDos Plus starts, and programs may use them at any time.
  2521.  
  2522.         WARNING:  Semaphore  0  is  present  but is  used  internally  by 
  2523.         MultiDos Plus to control access to DOS services.  Programs  which 
  2524.         get  or  attempt  to release semaphore 0 may interfere  with  DOS 
  2525.         access.
  2526.  
  2527.         An  additional  set of 32 semaphores are also available  but  are 
  2528.         referenced  by name rather than a number.  Names may be  anything 
  2529.         that  programs  choose to use but are limited to a maximum  of  8 
  2530.         characters in length. Once used, names are remembered by MultiDos 
  2531.         Plus  and do not disappear until MultiDos Plus is  terminated  or 
  2532.         the  system is rebooted.  Named semaphores are used internally by 
  2533.         MultiDos  Plus  when applications post read/write  calls  to  DOS 
  2534.         drivers  which support IOCTL calls.  Consequently,  the number of 
  2535.         named  semaphores available for application use may be less  than 
  2536.         32.
  2537.  
  2538.         Semaphore operations include the ability to get (function codes 1 
  2539.         and 27),  release (function codes 2 and 28),  or check the status 
  2540.         (function  codes  16  and 29) of a  given  semaphore.  A  program 
  2541.         issuing a call to get a semaphore will return immediately if  the 
  2542.         semaphore is free or available.  The semaphore is then considered 
  2543.         to  be  owned by the program until the program releases it  at  a 
  2544.         later  point.  A  program attempting to get a semaphore  will  be 
  2545.         suspended if the specified semaphore is owned by another program.
  2546.  
  2547.         Semaphores  may  be used to handle a variety  of  synchronization 
  2548.         problems but are generally used in the following two situations:
  2549.  
  2550.          1)    Two  cooperating  tasks  may  wish  to  synchronize  their 
  2551.         execution  and  attempt  to  get a  semaphore  in  a  prearranged 
  2552.         sequence. The second task attempting to get the semaphore will be 
  2553.         suspended.  The  first  task may schedule the  execution  of  the 
  2554.         second by releasing the semaphore at the appropriate time.
  2555.  
  2556.         2)  The most common use of semaphores is to control the access to 
  2557.         certain  system  resources.  These resources may be  hardware  or 
  2558.         software  resources.  An example of a hardware resource may be  a 
  2559.         device  such  as a communications port which may be used  by  any 
  2560.         program  but must be accessed in an exclusive manner.  A software 
  2561.         resource could be a function or a driver which is not  reentrant. 
  2562.         Programs  accessing such resources should control their access by 
  2563.         getting a semaphore prior to accessing the resource and releasing 
  2564.         it, after the use of the resource.  This technique will guarantee 
  2565.         exclusive use of the resource when it is in use.
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.                                      (37)
  2573.  
  2574.  
  2575.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2576.  
  2577.         Get Ownership of a Resource Semaphore
  2578.  
  2579.         Function Code = 1
  2580.  
  2581.         Entry:
  2582.                 AH = function code
  2583.                 AL = resource semaphore number (0 - 63)
  2584.  
  2585.         Exit:
  2586.                 AH =    0 if no error
  2587.                         2 if resource semaphore number is invalid
  2588.  
  2589.         The  ownership  of the resource semaphore is tested  and  if  not 
  2590.         owned by another task, ownership is given to the calling task and 
  2591.         control  returns immediately.  If the resource semaphore is owned 
  2592.         by  another task,  the calling task is suspended until the  owner 
  2593.         gives  up  control.  If several tasks request the  same  resource 
  2594.         semaphore,  the tasks are suspended and placed in a FIFO queue to 
  2595.         wait for the resource semaphore to become available.
  2596.  
  2597.  
  2598.         Release Ownership of a Resource Semaphore
  2599.         Function Code = 2
  2600.  
  2601.         Entry:
  2602.                 AH = function code
  2603.                 AL = resource semaphore number (0 - 63)
  2604.  
  2605.         Exit:
  2606.                 AH =    0 if no error
  2607.                         1 if the task does not own the resource semaphore
  2608.                         2 if the resource semaphore number is invalid
  2609.  
  2610.         This  function  releases  ownership  of  the  specified  resource 
  2611.         semaphore.  If  a task is waiting for the resource,  the  waiting 
  2612.         task  will  become  the  new owner  and  will  be  scheduled  for 
  2613.         execution.   If  several  tasks  are  waiting  for  the  resource 
  2614.         semaphore,  the  first  task  that  requested it  will  be  given 
  2615.         ownership.  The other waiting tasks will remain on the queue  and 
  2616.         wait for their turn at ownership.
  2617.  
  2618.         WARNING:  Do  not  use  this  function in  an  interrupt  service 
  2619.         routine.  The task which was interrupted may not be the owner  of 
  2620.         the resource semaphore.
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.                                      (38)
  2639.  
  2640.  
  2641.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2642.  
  2643.         Test Ownership of a Resource Semaphore
  2644.         Function Code = 16
  2645.  
  2646.         Entry:
  2647.                 AH = function code
  2648.                 AL = resource semaphore number (0 - 63)
  2649.  
  2650.         Exit:
  2651.                 AH =    0 if resource is not reserved
  2652.                         1 if resource is reserved
  2653.                         2 if the resource semaphore does not exist
  2654.                         3 if the task already owns the resource semaphore
  2655.  
  2656.         This  function  tests  if  the specified  resource  semaphore  is 
  2657.         already  owned.  You will probably want to use this  function  in 
  2658.         conjunction  with function codes 13 (Disable Multitasking) and 14 
  2659.         (Enable Multitasking) to disable the time slice scheduling  while 
  2660.         your task is checking the resource semaphore.  If the resource is 
  2661.         available,  then  the  task  can issue the function  to  get  the 
  2662.         resource before some other task can get the resource. This may be 
  2663.         important  if a task wants to get ownership of a resource without 
  2664.         getting suspended.
  2665.  
  2666.  
  2667.  
  2668.         Map Name to Number
  2669.         Function Code = 26
  2670.  
  2671.         Entry:
  2672.                 AH = function code
  2673.                 DS:SI = pointer to name string
  2674.  
  2675.         Exit:
  2676.                 AL =    0H              no error
  2677.                         4H              out of string space
  2678.                 AH =    resource semaphore number if no error
  2679.  
  2680.         This function is used internally by function codes 27,  28 and 29 
  2681.         to  equate a string with a resource semaphore  number.  The  name 
  2682.         string  pointed to by DS:SI consists of 8 bytes all of which  are 
  2683.         significant,  and it is not null terminated.  If the name already 
  2684.         exists,  the  number  associated  with that name is  returned  in 
  2685.         register AH.  If the name does not yet exist,  it is entered into 
  2686.         the name table;  and a free number is assigned to the name. Up to 
  2687.         32  names may be created,  and the numbers assigned to them  will 
  2688.         start  with 32 and range up to 63.  Once a name  is  created,  it 
  2689.         cannot be destroyed.
  2690.  
  2691.         Function  codes  27,  28,  and 29 are the equivalent of  invoking 
  2692.         function  code  26  followed  by  function  code  1,  2,  and  16 
  2693.         respectively.
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.                                      (39)
  2705.  
  2706.  
  2707.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2708.  
  2709.         Get Resource Semaphore by Name
  2710.         Function Code = 27
  2711.  
  2712.         Entry:
  2713.                 AH = function code
  2714.                 DS:SI = pointer to name string
  2715.  
  2716.         Exit:
  2717.                 AH =    0H      resource semaphore is now reserved
  2718.                         2H      illegal resource semaphore number
  2719.                         3H      invoking task already owns semaphore
  2720.                         4H      out of string space
  2721.  
  2722.         The  ownership  of  the resource  semaphore  is  tested;  and  if 
  2723.         unowned,  ownership  is  given  to the calling task  and  control 
  2724.         returns  immediately.  If the resource is owned by another  task, 
  2725.         the  calling task is suspended until the owner gives up  control. 
  2726.         If several tasks request the same resource semaphore,  the  tasks 
  2727.         are  suspended  and  are placed in a FIFO queue to wait  for  the 
  2728.         resource to become available.  See function code 1 (Get Ownership 
  2729.         of  a  Resource Semaphore) for more details on  getting  resource 
  2730.         semaphore ownership.
  2731.  
  2732.  
  2733.  
  2734.         Release Resource Semaphore by Name
  2735.         Function Code = 28
  2736.  
  2737.         Entry:
  2738.                 AH = function code
  2739.                 DS:SI = pointer to name string
  2740.  
  2741.         Exit:
  2742.                 AH =    0H      resource semaphore is available
  2743.                         1H      resource semaphore is not available
  2744.                         2H      illegal resource number
  2745.                         3H      invoking task already owns semaphore
  2746.                         4H      out of string space
  2747.  
  2748.         This function releases ownership of the named resource semaphore. 
  2749.         See  function code 2 (Release Ownership of a Resource  Semaphore) 
  2750.         for  more  details  about  releasing  ownership  of  a   resource 
  2751.         semaphore.
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.                                      (40)
  2771.  
  2772.  
  2773.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2774.  
  2775.         Test Resource Semaphore by Name
  2776.         Function Code = 29
  2777.  
  2778.         Entry:
  2779.                 AH = function code
  2780.                 DS:SI = pointer to name string
  2781.  
  2782.         Exit:
  2783.                 AH =    0H      resource semaphore is available
  2784.                         1H      resource semaphore is not available
  2785.                         2H      illegal resource number
  2786.                         3H      invoking task already owns semaphore
  2787.                         4H      out of string space
  2788.  
  2789.         The  ownership  of  the resource semaphore named  in  the  string 
  2790.         pointed  to by DS:SI is tested,  and the results of the test  are 
  2791.         placed  in the AH register on return.  See function code 16 (Test 
  2792.         Ownership  of  a  Resource Semaphore)  for  more  information  on 
  2793.         testing resource semaphores.
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.                                      (41)
  2837.  
  2838.  
  2839.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2840.  
  2841.         INTERTASK MESSAGING FUNCTIONS
  2842.         -----------------------------
  2843.  
  2844.         The  Intertask  Message  Facility is a convenient  mechanism  for 
  2845.         programs  running under MultiDos Plus to rapidly  exchange  data. 
  2846.         API  calls are available for tasks or programs to send  (function 
  2847.         code  4),  receive (function code 6) and check (function code  5) 
  2848.         for the presence of messages.
  2849.  
  2850.         MultiDos Plus provides 64 message queues (or mail boxes) numbered 
  2851.         0  through  63.  These queues are created when MultiDos  Plus  is 
  2852.         started  and  are available at any time for programs to  send  or 
  2853.         receive data. Unlike other multitasking environments, there is no 
  2854.         need to create, use and subsequently destroy message queues.
  2855.  
  2856.         When  a task sends a message to a message queue,  the contents of 
  2857.         the  message  buffer are copied to a buffer in a  message  buffer 
  2858.         pool.  This buffer is queued on a data structure associated  with 
  2859.         the  message  queue.  The  task sending the message  is  free  to 
  2860.         continue its execution and also to reuse its message buffer.
  2861.  
  2862.         The  buffer pool,  where copies of the messages are maintained by 
  2863.         MultiDos  Plus,  is  the unused conventional memory pool  in  the 
  2864.         system.  Therefore,  if  all  the memory is assigned  to  various 
  2865.         application  programs  (by means of RM  commands  and/or  loading 
  2866.         programs  until  memory  runs  out),  there  will  be  no  memory 
  2867.         available for the message buffer pool and intertask communication 
  2868.         will not be possible.
  2869.  
  2870.         The  size  of an individual message is limited to the smaller  of 
  2871.         64K or the size of the largest free memory block.
  2872.  
  2873.         Tasks which attempt to read a message from a queue are  suspended 
  2874.         if  there  is no message pending on the queue.  If a  message  is 
  2875.         pending,  its  contents  are  immediately copied to  the  receive 
  2876.         buffer and execution continues.  Multiple tasks may post reads on 
  2877.         a  single  message queue.   These tasks are queued up in  a  FIFO 
  2878.         manner  and receive the messages in the order in which  they  are 
  2879.         received on the queue.
  2880.  
  2881.         If  any  task  is waiting to receive a message on  the  specified 
  2882.         queue,  the  message buffer contents are copied to the  receiving 
  2883.         task's buffer area, after which the task that was waiting for the 
  2884.         message is scheduled. 
  2885.  
  2886.         Tasks  which read a message queue must specify the length of  the 
  2887.         receive buffer so that MultiDos Plus can ensure that the  receive 
  2888.         buffer is not overrun. MultiDos Plus will always transfer as many 
  2889.         bytes as it can without overrunning the receive buffer.
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.                                      (42)
  2903.  
  2904.  
  2905.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2906.  
  2907.         As  noted  earlier,   applications  do  not  create  queues;  and 
  2908.         therefore,  there  is  no  notion of "ownership" of  the  queues. 
  2909.         Programs  are  free to write to and read from message  queues  as 
  2910.         they please.  It is, therefore, necessary for the system designer 
  2911.         of the various applications to coordinate the use of the  various 
  2912.         message queues.
  2913.  
  2914.         Cooperating  programs  may set up shared memory areas by  sending 
  2915.         the  address  and the size of the area to another program  via  a 
  2916.         message  queue.  Since  Multidos Plus runs under the  real  mode, 
  2917.         there  is no memory protection;  and any program may  access  any 
  2918.         part  of  the first megabyte.  NOTE:  This technique may  not  be 
  2919.         possible for programs running in LIM memory.
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.                                      (43)
  2969.  
  2970.  
  2971.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  2972.  
  2973.         Send a Message to Another Task
  2974.         Function Code = 4
  2975.  
  2976.         Entry:
  2977.                 AH = function code
  2978.                 AL = message queue number (0 - 63)
  2979.                 DS:SI = message buffer pointer
  2980.                 CX = length of message
  2981.  
  2982.         Exit:
  2983.                 AH =    0 if okay
  2984.                         1 no system memory for message
  2985.                         2 if illegal message queue number
  2986.  
  2987.         Send a message to another task via a message queue.  The contents 
  2988.         of  the buffer pointed to by DS:SI are copied to a system  buffer 
  2989.         allocated  from the MultiDos Plus available memory pool,  and the 
  2990.         system buffer is added to the end of the specified message queue. 
  2991.         As soon as this function returns to the invoking task, the task's 
  2992.         message buffer may be used for another message without disturbing 
  2993.         the previous message.
  2994.  
  2995.  
  2996.         Check Message Queue for a Message
  2997.         Function Code = 5
  2998.  
  2999.         Entry:
  3000.                 AH = function code
  3001.                 AL = message queue number (0 - 63)
  3002.  
  3003.         Exit:
  3004.                 AH=      0 if no error
  3005.                          2 illegal message queue number
  3006.                 DX=      0 if no message, else the length of
  3007.                            the first message in the queue
  3008.  
  3009.         Check  if the specified message queue has an  available  message. 
  3010.         Control is returned immediately. The function does not wait for a 
  3011.         message  to  be  placed  on the message  queue.  In  addition  to 
  3012.         checking  for the presence of a message,  this function  is  also 
  3013.         useful  for  determining  the size of a message  before  actually 
  3014.         attempting to get the message.  The task can then insure that the 
  3015.         buffer it passes to get the message will be large enough to  hold 
  3016.         the entire message.
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.                                      (44)
  3035.  
  3036.  
  3037.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3038.  
  3039.         Get a Message from a Message Queue
  3040.         Function Code = 6
  3041.  
  3042.         Entry:
  3043.                 AH = function code
  3044.                 AL = message queue number (0 - 63)
  3045.                 ES:DI = buffer pointer to put message in
  3046.                 CX = number of bytes in buffer 
  3047.  
  3048.         Exit:
  3049.                 AH = 0 no error
  3050.                 CX = number of bytes transferred
  3051.                 DX = actual message length
  3052.                         or
  3053.                 AH = 2 illegal message queue number
  3054.  
  3055.         Read  a  message  from the specified  message  semaphore.  If  no 
  3056.         message is present, the task is suspended until one is available.
  3057.  
  3058.         If a task does not know the maximum size of a message,  it should 
  3059.         issue   a function code 5 (Check Message Queue for a Message)  to 
  3060.         check  a message queue for the size of a message before  actually 
  3061.         reading  the message.  If the buffer is not large enough to  hold 
  3062.         the message,  the message is truncated before it is placed in the 
  3063.         calling task's buffer. The truncated part of the message is lost.
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.                                      (45)
  3101.  
  3102.  
  3103.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3104.  
  3105.         EVENT TRIGGER FUNCTIONS
  3106.         -----------------------
  3107.  
  3108.         A  useful  feature provided by MultiDos Plus is a  mechanism  for 
  3109.         having a task wait for a specific event to occur.  While the task 
  3110.         is  waiting,  it  is  suspended on a queue and will not  use  any 
  3111.         processor time.  When an event occurs, the process triggering the 
  3112.         event (such as an interrupt handler) invokes a MultiDos Plus  API 
  3113.         call to signal that the event has occurred.  If a task is waiting 
  3114.         for the event,  it is scheduled. If no task is waiting, a counter 
  3115.         for the event is incremented.
  3116.  
  3117.         There  are 64 Event Triggers defined in MultiDos Plus.  Each  one 
  3118.         consists  of  a  16-bit counter and an  associated  task  waiting 
  3119.         queue. When an Event Trigger function is invoked, a number from 0 
  3120.         to 63 is specified to indicate on which counter/queue to operate.
  3121.  
  3122.         The  Event Trigger functions are all available through the single 
  3123.         interrupt  15H  function code 30.  Each  individual  function  is 
  3124.         specified   by   a  subfunction  code  in  register   AL.   Three 
  3125.         subfunctions  are defined to clear the counter (subfunction  code 
  3126.         0),  wait for an event (subfunction code 2),  and to trigger  the 
  3127.         event (subfunction code 1). The following describes the interface 
  3128.         to these subfunctions.
  3129.  
  3130.  
  3131.         Clear Event Counter
  3132.         Function Code = 30 subfunction = 0
  3133.  
  3134.         Entry:
  3135.              AH = function code
  3136.              AL = subfunction code
  3137.              DX = event/trigger number (0 - 63)
  3138.  
  3139.         Exit:
  3140.              AH = 0 no error
  3141.  
  3142.         This  function clears the counter for the specified event/counter 
  3143.         number.  This  function  can be invoked by either a  task  or  an 
  3144.         interrupt service routine.
  3145.  
  3146.         NOTE:  A counter will roll over after 65,536 events have occurred 
  3147.         and none have been serviced.
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.                                      (46)
  3167.  
  3168.  
  3169.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3170.  
  3171.          Signal Event
  3172.          Function Code = 30 subfunction = 1
  3173.          
  3174.          Entry:
  3175.                 AH = function code
  3176.                 AL = subfunction code
  3177.                 DX = event/trigger number (0 - 63)
  3178.          
  3179.          Exit:
  3180.               AH =     0 no error
  3181.                        1 invalid event/trigger number
  3182.  
  3183.         This  subfunction is used to signal a waiting task that an  event 
  3184.         has occurred. This function may be invoked either by another task 
  3185.         or by an interrupt service routine.  If a task is waiting for the 
  3186.         event, it is scheduled for execution.
  3187.  
  3188.         If no task is waiting,  then the counter is incremented by one to 
  3189.         indicate  that  an  event occurred.  If more  than  65,536  event 
  3190.         signals are received, the counter will roll over to zero.
  3191.  
  3192.  
  3193.          Wait for Event
  3194.          Function Code = 30 subfunction = 2
  3195.          
  3196.          Entry:
  3197.                 AH = function code
  3198.                 AL = subfunction code
  3199.                 DX = event/trigger number (0 - 63)
  3200.          
  3201.          Exit:
  3202.                 AH =    0       no error
  3203.                         1       invalid event/trigger number
  3204.          
  3205.         A task issues this function to wait for an event to occur. If the 
  3206.         value  of  the counter is zero,  the invoking task  is  suspended 
  3207.         until  another  task  or  an interrupt  service  routine  invokes 
  3208.         subfunction 1 (Signal Event). If the counter is not zero, control 
  3209.         is returned immediately to the calling task;  and the counter  is 
  3210.         decremented by one.
  3211.  
  3212.         A potential use for an Event Trigger is a cooperative arrangement 
  3213.         between  a  task  (or  several tasks) and  an  interrupt  service 
  3214.         routine.   If  an  interrupt  service  routine  has  the  job  of 
  3215.         collecting  data and placing it in a buffer,   it would notify  a 
  3216.         task waiting for the event when the buffer is full.  The  waiting 
  3217.         task  would then service the full buffer (when it is its turn  to 
  3218.         receive a time slice) and return to wait for the next event.
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.                                      (47)
  3233.  
  3234.  
  3235.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3236.  
  3237.         CHAPTER V
  3238.         ---------
  3239.  
  3240.         INSIDE MULTIDOS PLUS
  3241.         --------------------
  3242.  
  3243.         The  file MULTIDOS.EXE is the only file required to use  MultiDos 
  3244.         Plus.  It contains the multitasking kernal which provides all the 
  3245.         MultiDos  Plus features except for those provided by the  display 
  3246.         driver (MDBIO10.EXE). If your application will only have one task 
  3247.         which  will  ever write to the CRT,  there is no need to  install 
  3248.         MDBIO10 on startup.  Therefore,  the only files you may ever need 
  3249.         to  run MultiDos Plus are MULTIDOS.EXE and  perhaps  MDBIO10.EXE. 
  3250.         This  chapter  will  describe some of the inner workings  of  the 
  3251.         MULTIDOS.EXE program which may help you to better understand  how 
  3252.         to use MultiDos Plus for your application.
  3253.  
  3254.         MultiDos Plus Startup
  3255.  
  3256.         When the MULTIDOS.EXE program begins execution, it goes through a 
  3257.         complex initialization process.  During initialization,  a number 
  3258.         of  data  structures are created and initialized followed by  the 
  3259.         "hooking" of a number of the interrupt vectors.  All the  command 
  3260.         line parameter options are examined; and the appropriate internal 
  3261.         flags, etc. are set for later use.
  3262.  
  3263.         During  intialization,  the  memory for the Task  Control  Blocks 
  3264.         (TCB)  is allocated.  The value specified with the /NUMTCB option 
  3265.         is used as the number of TCBs to create.  If no /NUMTCB option is 
  3266.         specified,  a  default value of 12 is used.  When specifying  the 
  3267.         number  of  TCBs,  keep  in mind that  two  additional  TCBs  are 
  3268.         required  by MultiDos Plus for internal use.  Also,  when a  task 
  3269.         executes a DOS child process function,  each active child process 
  3270.         requires an additional TCB.
  3271.  
  3272.         The size of the TCB is determined by the /CTX option.  If /CTX is 
  3273.         not specified,  the TCB will only be about 224 bytes.  If /CTX is 
  3274.         specified,  the TCB will be about 624 bytes.  The actual size may 
  3275.         vary  slightly depending on the version of MultiDos Plus you  are 
  3276.         using.
  3277.  
  3278.         Once the TCBs have been allocated, the first two are used for two 
  3279.         internal  tasks,  the MULTIDO and the IDLE tasks.  If you use the 
  3280.         "L" command in MDDEBUG,  the first TCB is MULTIDO and the  second 
  3281.         is IDLE. These two tasks are created during initialization.
  3282.  
  3283.         The  interrupt vectors "hooked" into by MultiDos Plus are  8,  9, 
  3284.         12H, 15H, 16H, 20H, 21H, 22H, 23H, 24H, 25H, 26H, 27H. If MDBIO10 
  3285.         is  loaded,  interrupt 10H is also "hooked".  If your application 
  3286.         needs to make use of any of these interrupts,  you must take care 
  3287.         to  pass control  to the MultiDos Plus interrupt handler  if  the 
  3288.         interrupt  is not applicable to your application.   For the  most 
  3289.         part  MultiDos Plus tries to preserve the DOS or BIOS meaning  of 
  3290.         the interrupt with multitasking in mind.
  3291.  
  3292.         Once the INT 8 interrupt vector is "hooked",  the multitasking is 
  3293.         initiated.  The  initialization routine becomes the MULTIDO  task 
  3294.         which is described below.
  3295.  
  3296.  
  3297.  
  3298.                                      (48)
  3299.  
  3300.  
  3301.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3302.  
  3303.         The Command Task
  3304.  
  3305.         The  Command  Task  is the main MultiDos Plus task  and  performs 
  3306.         several different functions.  The task name in the TCB is MULTIDO 
  3307.         which can be examined with various MDDEBUG commands. As mentioned 
  3308.         above,  the Command Task is a continuation of the  initialization 
  3309.         process  and  comes  into being as soon as  the  multitasking  is 
  3310.         turned on by "hooking" interrupt 8.
  3311.  
  3312.         The  first  function  performed  is the loading  of  the  MDBIO10 
  3313.         driver,  if required. Once MDBIO10 is loaded, a delay of 18 ticks 
  3314.         is  executed  to  give  MDBIO10 plenty of  time  to  perform  its 
  3315.         initialization.  To  make the new interrupt vector a part of  the 
  3316.         Command Task display context,  the content of the System  Block's 
  3317.         "pointer  to  new  interrupt  10H"  is  placed  into  the  actual 
  3318.         interrupt 10H vector.
  3319.  
  3320.         Next  is the processing of the AUTO.MTX startup file,  if one  is 
  3321.         present.  During  the  execution of the  AUTO.MTX,  only  command 
  3322.         processing takes place.  If a started task attempts to use any of 
  3323.         the other services provided by the Command Task, they will not be 
  3324.         performed until the AUTO.MTX processing is finished.
  3325.  
  3326.         The  Command  Task  will now enter its main function  loop  which 
  3327.         continually  checks several queues for requests and then reads  a 
  3328.         character  from the keyboard.  If there is no character to  read, 
  3329.         the  Command  Task suspends itself for at least one  timer  tick. 
  3330.         When  the MULTIDO task is in the background,  it suspends  itself 
  3331.         for  4 ticks before scanning the queues and looking for  an  ALTZ 
  3332.         key.
  3333.  
  3334.         Besides  interpreting  MultiDos Plus commands,  the Command  Task 
  3335.         also  provides  services for  inter-task  communication,  program 
  3336.         loading, program termination, foreground/background switching and 
  3337.         task  command execution.  All these functions are initiated  when 
  3338.         the Command Task finds a request for these services on one of the 
  3339.         request  queues.  These queues are checked each time the  Command 
  3340.         Task wakes up.
  3341.  
  3342.         The "IDLE" Task
  3343.  
  3344.         The "IDLE" Task is a very simple task which exists solely for the 
  3345.         purpose  of  giving  the system something to  do  when  there  is 
  3346.         nothing else that needs to be done.  The "IDLE" Task is always in 
  3347.         a  loop  which continually gives up its time slice by issuing  an 
  3348.         API function code 0 (Give Up Time Slice) call.
  3349.  
  3350.         The General Application Environment
  3351.  
  3352.         When  a COM or EXE program begins execution as a  loaded  program 
  3353.         under  MultiDos Plus,  it can usually execute as if MultiDos Plus 
  3354.         was not in the system and the program was started by DOS.
  3355.  
  3356.         Each program has a PSP block built for it just as if the  program 
  3357.         had been loaded by DOS.  This gives each task its own environment 
  3358.         string  (which  is  a copy of the environment  present  when  the 
  3359.         MULTIDOS.EXE  first  began  execution) and separate  file  handle 
  3360.         table.  The  PSP will also have the command line string which  is 
  3361.  
  3362.  
  3363.  
  3364.                                      (49)
  3365.  
  3366.  
  3367.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3368.  
  3369.         taken from the command line that loaded the program. As mentioned 
  3370.         in  earlier  chapters,  no standard input/output  redirection  is 
  3371.         provided by MultiDos Plus.  The first five file handles of a task 
  3372.         are  inherited from the MultiDos Plus PSP.  The DOS CLOSE  HANDLE 
  3373.         function will not close a handle less than 5.  If attempted,  the 
  3374.         function  returns a normal completion code with no error  to  the 
  3375.         calling task.
  3376.  
  3377.  
  3378.         DOS Services
  3379.  
  3380.         Tasks are normally free to make use of DOS interrupt 21H services 
  3381.         as if they are the only program in the system. MultiDos Plus uses 
  3382.         Resource  Semaphore 0 to control access to DOS without the  tasks 
  3383.         being aware of the process. In addition, a number of DOS services 
  3384.         are  provided directly by MultiDos Plus so as not to tie up  DOS. 
  3385.         These  are  normally functions which read from the  keyboard  and 
  3386.         write to the CRT display.
  3387.  
  3388.         When  a  task  issues  an INT 21H for  a  DOS  function,  several 
  3389.         functions  are  performed  just  before  entry  to  the  old  DOS 
  3390.         interrupt vector.  MultiDos Plus sets the DTA and the Process  ID 
  3391.         for the task. The Process ID is the task's PSP segment and is set 
  3392.         using  DOS  function  code 50H.  Also,  if the  /CTX  option  was 
  3393.         specified  when MultiDos Plus was invoked,  the directory context 
  3394.         of  the task is restored.  When the task returns  from  DOS,  the 
  3395.         directory context will be saved in the task's TCB.
  3396.  
  3397.         Task Scheduling
  3398.  
  3399.         MultiDos  Plus  provides a preemptive multitasking  system  which 
  3400.         offers  a  choice  of  two  different  scheduling  schemes.   The 
  3401.         interrupt  8  timer  is used to preempt  executing  tasks.  Tasks 
  3402.         waiting  for  execution  are held in a Ready  Queue  and  receive 
  3403.         slices of processor time. When the interrupt 8 timer expires, the 
  3404.         currently  executing task is suspended and placed at the  end  of 
  3405.         the  Ready Queue.  The next task on the queue is then allowed  to 
  3406.         execute until the timer expires again.
  3407.  
  3408.         The default scheme of selecting the next task to execute from the 
  3409.         Ready Queue removes the task at the head of the queue, checks its 
  3410.         scheduling  counter  and if zero,  the task is executed.  If  the 
  3411.         scheduling  counter  is not zero,  it is decremented by  one  and 
  3412.         placed at the end of the Ready Queue.  If the scheduling  counter 
  3413.         is  decremented  to  zero,  the counter is reset  to  the  task's 
  3414.         priority  level;  and the task is allowed to execute.  Using this 
  3415.         type  of scheduling scheme,  all tasks will eventually receive  a 
  3416.         time slice.  When a task is loaded,  its priority level is set to 
  3417.         zero.
  3418.  
  3419.         A  second type of scheduling scheme may be selected by using  the 
  3420.         /PR  command line option when MultiDos Plus is started.  The  /PR 
  3421.         option changes the way MultiDos Plus selects tasks from the Ready 
  3422.         Queue for execution. A task is selected by scanning all the tasks 
  3423.         on  the  Ready Queue.  The task with the highest  priority  level 
  3424.         (lowest value) is selected for execution.  If several tasks  have 
  3425.         the  same priority level and they have the highest priority,  the 
  3426.         task closest to the head of the queue is  selected.  Thus,  tasks 
  3427.  
  3428.  
  3429.  
  3430.                                      (50)
  3431.  
  3432.  
  3433.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3434.  
  3435.         with equal priority will execute in a round robin manner. The use 
  3436.         of  this  scheme  can  provide high priority  tasks  with  highly 
  3437.         reliable  scheduling for critical real time  events.  NOTE:  High 
  3438.         priority  tasks should make use of API function code  3  (Suspend 
  3439.         Task  for  Interval)  to avoid monopolizing all of  the  system's 
  3440.         processing  time.  The  API  Event Triggers  are  also  good  for 
  3441.         controlling high priority tasks.
  3442.  
  3443.         The scheme for selecting the next task for execution also applies 
  3444.         when  an executing task gives up its processing time by giving up 
  3445.         its  time  slice,   suspending  itself,   requesting  a  resource 
  3446.         semaphore, getting a message from a message queue, or waiting for 
  3447.         an event. 
  3448.  
  3449.         Task Context Switch
  3450.  
  3451.         There  are a number of instances where MultiDos Plus will save  a 
  3452.         running task's context, place the task's TCB on a queue, find the 
  3453.         next  task  ready to run,  switch in the new task's  context  and 
  3454.         resume execution with the new task.  A context switch occurs when 
  3455.         a  task executes an interrupt 15H API function which  causes  the 
  3456.         task  to be blocked from execution or when the interrupt 8  timer 
  3457.         interrupt  occurs.  It  is the interrupt 8 timer interrupt  which 
  3458.         preempts  the  running task and the context switch  is  performed 
  3459.         before the old timer interrupt handler code is executed.
  3460.  
  3461.         A task's context information consists of registers  AX,  BX,  CX, 
  3462.         DX,  BP,  DI,  SI,  DS,  ES,  CS,  IP, FLAGS, SS, and SP. All the 
  3463.         register  context is saved on the task's stack with the exception 
  3464.         of the SS and SP registers which are saved in the task's TCB. The 
  3465.         interrupt 10H interrupt vector is also saved in the TCB;  and  if 
  3466.         the  task  uses LIM memory,  the LIM context is also saved  in  a 
  3467.         block of memory attached to the task's TCB.
  3468.  
  3469.         Internal Tasks (Threads)
  3470.  
  3471.         MultiDos  Plus supports the concept of internal tasks or  threads 
  3472.         within  the  same  program.  A program may start  subroutines  or 
  3473.         functions as separate processes called internal tasks.
  3474.  
  3475.         The  concept of internal tasks offer several obvious  advantages. 
  3476.         The  various  tasks can easily share data  without  resorting  to 
  3477.         intertask communication or other means. The other major advantage 
  3478.         is that reentrant code can be shared between the tasks, resulting 
  3479.         in significantly smaller memory requirements.
  3480.  
  3481.         Greater care is needed in implementing a system based on internal 
  3482.         tasks.  The  major consideration is to examine the code that will 
  3483.         be  shared  by  the various tasks and  determine  whether  it  is 
  3484.         reentrant. Though this is fairly easy to determine in the case of 
  3485.         assembler  code,  determining  the  reentrancy  of  higher  level 
  3486.         language  code may be difficult.  Even if the code written by the 
  3487.         MultiDos  Plus  user is reentrant,  it should be noted  that  the 
  3488.         various tasks may reference library run-time functions which  may 
  3489.         or may not be reentrant.
  3490.  
  3491.         Internal  tasks  share the same Program Segment Prefix  with  the 
  3492.         parent,  with  the  result  that  files opened by  one  task  are 
  3493.  
  3494.  
  3495.  
  3496.                                      (51)
  3497.  
  3498.  
  3499.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3500.  
  3501.         available  to  the parent as well as other  children.  The  child 
  3502.         internal  tasks inherit other properties of the parent  including 
  3503.         the  memory  control blocks.  Memory allocation done by  a  child 
  3504.         internal task results in memory being allocated from the parent.
  3505.  
  3506.         MultiDos  Plus  automatically assigns names for  internal  tasks. 
  3507.         Unique  names are assigned to internal tasks by incrementing  the 
  3508.         last character of the parent task's name.  Internal tasks are not 
  3509.         shown when ALTZ is done and cannot be brought to the foreground.
  3510.  
  3511.         It  is  very  important  that  an  internal  task  terminate  its 
  3512.         execution  by using the API function code 8  (Terminate  Internal 
  3513.         Task).   Using   a  DOS  termination  function  will  result   in 
  3514.         unpredictable results.
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.  
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.                                      (52)
  3563.  
  3564.  
  3565.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3566.  
  3567.         RUNNING WITH A LIM 4.0 EMM DRIVER
  3568.  
  3569.         MultiDos  Plus fully supports any LIM EMS memory you may have  in 
  3570.         your system.  A LIM driver version 4.0 or greater must be present 
  3571.         in  your  system in order for MultiDos Plus to take advantage  of 
  3572.         the LIM memory.
  3573.  
  3574.         On  386 PCs no hardware LIM boards need to be present as long  as 
  3575.         you have a suitable software emulator which conforms to LIM  4.0. 
  3576.         For  286 as well as 8088 based systems you must have a LIM  board 
  3577.         with the appropriate LIM 4.0 driver.  NOTE:  Certain 286 PCs have 
  3578.         LIM  4.0 emulators which enable you to use extended memory as LIM 
  3579.         4.0 memory.  However, this technique will not be suitable for use 
  3580.         under MultiDos Plus as the map switching will not be fast enough.
  3581.  
  3582.         Certain  older  LIM boards such as the Intel Above Board  may  be 
  3583.         controlled  by  a LIM 4.0 driver but provide mappable  memory  of 
  3584.         only  64K.  These boards will severely restrict the size  of  the 
  3585.         programs you can run in LIM memory.
  3586.  
  3587.         Newer  LIM boards which provide hardware support for the LIM  4.0 
  3588.         specification  such  as  the Intel Above Board PLUS  or  the  AST 
  3589.         Rampage  Plus  are highly desirable for use under MultiDos  Plus. 
  3590.         However,  even with these boards, your hardware configuration may 
  3591.         limit the amount of mappable EMS memory.  The ideal configuration 
  3592.         for MultiDos Plus is a 386 PC with a LIM 4.0 memory manager or  a 
  3593.         PC/AT  with  conventional  memory limited to 256K with  the  rest 
  3594.         supplied  by  a  LIM  4.0 board  with  the  ability  to  backfill 
  3595.         conventional memory to 640K.  For faster context switches, boards 
  3596.         supporting alternate map sets are desirable.
  3597.  
  3598.         Nanosoft  Inc.  has  tested various configurations but  does  not 
  3599.         explicitly  endorse any single product due to the large number of 
  3600.         boards  and emulators available in the market.  It is up  to  the 
  3601.         user to determine the best configuration to suit your needs.
  3602.  
  3603.         MultiDos Plus permits your normal DOS programs to run in expanded 
  3604.         memory  with  no  changes to your programs.  This  permits  large 
  3605.         multitasking  systems  to be developed without being  limited  by 
  3606.         memory. The code size of a single program is still limited by the 
  3607.         size  of the mappable page frame in your system (unless  overlays 
  3608.         are  used).   Programs  running in expanded memory  may  use  LIM 
  3609.         memory by means of standard LIM driver calls to map memory in the 
  3610.         LIM page frame. MultiDos Plus saves and restores map contexts for 
  3611.         all  programs  with  no special coding required on  the  part  of 
  3612.         application programs.
  3613.  
  3614.         Certain  terms  need  to  be fully understood in  order  to  make 
  3615.         effective  use of LIM memory under MultiDos  Plus.  The  MultiDos 
  3616.         Plus  Page  Frame is defined as the area of mappable  LIM  memory 
  3617.         used to load and execute application programs.  It is the largest 
  3618.         contiguous  area  of mappable LIM memory available in the  system 
  3619.         and  generally  starts at the first 16K boundary  after  MultiDos 
  3620.         Plus and extends up to your display memory. The LIM page frame is 
  3621.         a  64K area of memory usually starting at C000 or beyond  and  is 
  3622.         used  by  applications  to map LIM memory by  normal  LIM  driver 
  3623.         calls.  A  normal  DOS  program which uses LIM  memory  will  run 
  3624.         unchanged   under   MultiDos  Plus  whether  it  is   loaded   in 
  3625.  
  3626.  
  3627.  
  3628.                                      (53)
  3629.  
  3630.  
  3631.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3632.  
  3633.         conventional or LIM memory (in the MultiDos Page Frame).
  3634.  
  3635.         In  addition to the two page frames discussed,  most systems have 
  3636.         "holes"  in the first megabyte of memory where LIM memory can  be 
  3637.         mapped.  On  startup,  MultiDos Plus permanently maps LIM  memory 
  3638.         into  these "holes" and links them to the conventional memory  in 
  3639.         your  system.  This  may result in significant  increase  in  the 
  3640.         amount  of conventional memory in your system.  By  default,  the 
  3641.         "hole"  corresponding to the LIM page frame is not mapped on  the 
  3642.         assumption  that you may be running applications which explicitly 
  3643.         map LIM memory and need the use of the LIM page frame. If this is 
  3644.         not  the case the startup option /MAPALL will map  all  available 
  3645.         holes including the LIM page frame.  NOTE: This permanent mapping 
  3646.         does  not preclude applications from running in LIM memory in the 
  3647.         MultiDos Plus Page Frame.
  3648.  
  3649.         As noted earlier, programs may run in expanded memory without any 
  3650.         special  consideration.  There  are,  however,  some  exceptions. 
  3651.         Programs  running  in expanded memory performing  data  transfers 
  3652.         to/from  external devices triggered by hardware  interrupts  will 
  3653.         not  function  correctly.  This is due to the fact that the  data 
  3654.         transfer  may  take place when the map set  associated  with  the 
  3655.         program is not active.  To handle this situation, the command IRQ 
  3656.         lets  you  associate an IRQ number with a specific program's  map 
  3657.         set. Simply specify this parameter when you load the program, and 
  3658.         MultiDos  Plus  will  automatically  map  the  program  when  the 
  3659.         specified  interrupt occurs.  After the ISR is complete  MultiDos 
  3660.         Plus  will  remap the map context in effect  when  the  interrupt 
  3661.         occurred.  Currently  there is no provision to associate multiple 
  3662.         IRQs with a single program.
  3663.  
  3664.         Programs running in LIM memory may not set up shared memory areas 
  3665.         with other programs running in LIM.  They may do so with programs 
  3666.         running  in  conventional  memory  provided  that  the   programs 
  3667.         explicitly handle the mapping when necessary.
  3668.  
  3669.         MultiDos  Plus uses alternate map sets (if available) to  perform 
  3670.         rapid  context switching of LIM maps.  If alternate map sets  are 
  3671.         used  up (or if none are available to start with),  MultiDos Plus 
  3672.         saves and restores map contexts in internal save areas associated 
  3673.         with each program.
  3674.  
  3675.         DRIVERS UNDER MULTIDOS PLUS
  3676.  
  3677.         The discussion in this section applies to installable DOS  device 
  3678.         drivers as well as Interrupt Service Routines and TSRs.
  3679.  
  3680.         In  general,  drivers,  TSRs  and ISRs written for DOS will  work 
  3681.         under MultiDos Plus with no changes.  There  are,  however,  some 
  3682.         restrictions  when  expanded memory is used in  conjunction  with 
  3683.         MultiDos  Plus.   This  section  offers  general  guidelines  for 
  3684.         implementing  and  using  existing drivers under  MultiDos  Plus. 
  3685.         Having  a clear understanding of the MultiDos  Plus  architecture 
  3686.         will permit the user to circumvent most of the limitations.
  3687.  
  3688.         In  general,  all TSRs and ISRs must be loaded prior to  MultiDos 
  3689.         Plus.  DOS  installable drivers are of course always loaded  when 
  3690.         the  system  is booted.  Though MultiDos Plus permits TSRs to  be 
  3691.  
  3692.  
  3693.  
  3694.                                      (54)
  3695.  
  3696.  
  3697.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3698.  
  3699.         loaded as tasks under MultiDos Plus,  in most cases this approach 
  3700.         is not recommended.  TSRs which change interrupt vectors used  by 
  3701.         MultiDos Plus MUST be loaded before MultiDos Plus. 
  3702.  
  3703.         Any   software  which  gets  invoked  as  a  result  of  external 
  3704.         interrupts  may not normally reside in mappable expanded  memory. 
  3705.         The  external  interrupt would cause the  processor  to  transfer 
  3706.         control  to  code  which may not be  currently  mapped.  The  IRQ 
  3707.         command  described  in    Chapter II may be used to  handle  this 
  3708.         situation  but will result in significant  performance  overhead, 
  3709.         especially if the interrupts occur at a rapid rate.
  3710.  
  3711.         TSRs  and  ISRs  may  be  loaded  in  expanded  memory  which  is 
  3712.         permanently   mapped  (the  "holes"  in  high  memory  which  are 
  3713.         permanently  mapped by MultiDos Plus).  Any driver,  TSR  or  ISR 
  3714.         which  uses expanded memory (by making explicit LIM driver calls) 
  3715.         must save and restore the current task's map context.
  3716.  
  3717.         Standard DOS drivers are usually synchronous drivers (control  is 
  3718.         transferred  to  the application only after the driver  completes 
  3719.         the request).  Some drivers,  especially network related drivers, 
  3720.         are implemented as asynchronous drivers. Such drivers may need to 
  3721.         be  redesigned  if  they need  to  service  application  programs 
  3722.         running  in  expanded memory.  When a request is initiated  by  a 
  3723.         program,  the  driver must determine the TCB of the program,  and 
  3724.         later map the LIM map associated with the program to perform data 
  3725.         transfers to/from driver address space to program address  space. 
  3726.         If  drivers  are  implemented  to  service  multiple  application 
  3727.         programs, the driver must be reentrant.
  3728.  
  3729.         Drivers  and  ISRs  which are triggered  by  external  interrupts 
  3730.         should  not  use  most  of  the  MultiDos  Plus  API  calls.  The 
  3731.         exceptions  are  calls to determine the current TCB  and  certain 
  3732.         event trigger calls. It should be noted that ISRs may get invoked 
  3733.         at any arbitrary time and runs under the context of the user task 
  3734.         which  was interrupted.  Using MultiDos Plus system service calls 
  3735.         may,  therefore,  affect  the  execution of the  task  which  was 
  3736.         interrupted with unpredictable results.
  3737.  
  3738.         Event  trigger  calls  have  been designed for use  by  ISRs  and 
  3739.         drivers and should be the primary vehicle for communication  from 
  3740.         a driver to tasks running under MultiDos Plus.
  3741.  
  3742.         THE DISPLAY AND INTERRUPT 10H
  3743.  
  3744.         Well  behaved DOS programs either use DOS interrupt 21H functions 
  3745.         or  BIOS interrupt 10H functions to place data on the visual  CRT 
  3746.         display.  Even  the DOS interrupt 21H functions wind up  invoking 
  3747.         the BIOS interrupt 10H functions for display functions.  Based on 
  3748.         this,  MultiDos Plus includes a software driver which  intercepts 
  3749.         BIOS  interrupt  10H.  The driver will only allow the  foreground 
  3750.         program  to write data to the real CRT memory,  while  background 
  3751.         programs have their display data written to a different piece  of 
  3752.         memory.  This driver is the file MDBIO10.EXE which is included on 
  3753.         the distribution diskette.
  3754.  
  3755.         MDBIO10   supports  the  standard  BIOS  INT  10H  functions  for 
  3756.         background  tasks  for  the monochrome  and  the  color  graphics 
  3757.  
  3758.  
  3759.  
  3760.                                      (55)
  3761.  
  3762.  
  3763.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3764.  
  3765.         displays.  Other  display  adapter  modes are not  supported  for 
  3766.         background  tasks.  Foreground  tasks can use  any  display  mode 
  3767.         supported  by  your adapter hardware.  If the foreground task  is 
  3768.         using  an  unsupported  mode  and  the  task  is  moved  to   the 
  3769.         background, some of the contents of the display are lost.
  3770.  
  3771.         MDBIO10  is a Terminate Stay Resident program which performs some 
  3772.         initial  setup and then invokes DOS INT 21H function code 31H  to 
  3773.         terminate.  The  initialization sets the interrupt 10H vector  to 
  3774.         point to the MDBIO10 interrupt handler and sets the new interrupt 
  3775.         10H  pointer in the System Block before  terminating.  Subsequent 
  3776.         execution is initiated by MultiDos Plus tasks invoking  interrupt 
  3777.         10H.
  3778.  
  3779.         When  the driver is entered as a result of an interrupt 10H call, 
  3780.         MDBIO10  first  determines  if  the calling  program  is  in  the 
  3781.         foreground  or  in the background.  Display calls issued  by  the 
  3782.         foreground  program  are  passed through  to  the  original  BIOS 
  3783.         display handler.
  3784.  
  3785.         Display  output  of a background task is written to  its  virtual 
  3786.         screen.  The  virtual screen is on a paragraph boundary,  and its 
  3787.         segment address is in offset 18 of the TCB.
  3788.  
  3789.         Data  associated with the display for each task is maintained  in 
  3790.         its TCB. This area is identical to that maintained by BIOS in low 
  3791.         memory.
  3792.  
  3793.         USING THE MATH COPROCESSOR
  3794.  
  3795.         In the interest of performance,  MultiDos Plus does not save  and 
  3796.         restore  the  context of the 8087/80287/80387  math  coprocessors 
  3797.         when a task's context is switched at the end of a time slice.  If 
  3798.         more  than one task requires the use of the coprocessor,  one  of 
  3799.         the  resource  semaphores should be used to control access to  it 
  3800.         (See the README file for more information about 8087 context).
  3801.  
  3802.         The  first  step  is  for all tasks to agree  on  which  resource 
  3803.         semaphore  number  to  use.  Whenever a task  needs  to  use  the 
  3804.         coprocessor, it would issue INT 15 function code 1 (Get Ownership 
  3805.         of  a  Resource Semaphore) to get control.  When function code  1 
  3806.         returns with no error,  the task may begin using the coprocessor. 
  3807.         When  the  task is done,  it must issue INT 15  function  code  2 
  3808.         (Release Ownership of a Resource Semaphore) to release control of 
  3809.         the  coprocessor.  The coprocessor would now be available for use 
  3810.         by other tasks.
  3811.  
  3812.         Even if your system does not have a math co-processor,  the  run-
  3813.         time  package  supplied with your compiler may load a  driver  to 
  3814.         emulate  the  8087.  You  should still use a resource  number  to 
  3815.         control access to the driver since the driver will not know which 
  3816.         task  is  using the driver at any given moment.  This  will  also 
  3817.         prevent  non-reentrant drivers from being used by more  than  one 
  3818.         task at the same time.
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.                                      (56)
  3827.  
  3828.  
  3829.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3830.  
  3831.         USEFUL SYSTEM DATA STRUCTURES
  3832.  
  3833.         The Task Control Block
  3834.  
  3835.         A  Task  Control Block (TCB) is a data structure  which  contains 
  3836.         task related information needed by MultiDos Plus to keep track of 
  3837.         the  task.   Each task running under MultiDos Plus has a  TCB.  A 
  3838.         task  can obtain a pointer to its own TCB by issuing an interrupt 
  3839.         15H with a function code of 19 (Get Task Control Block  Address). 
  3840.         All TCBs are allocated in the same segment, and they all start on 
  3841.         a paragraph boundry.  The first TCB starts at byte offset 16. The 
  3842.         TCB  size in the system block can be used to calculate the  start 
  3843.         of  any  TCB  in the system.  The following  table  contains  the 
  3844.         definitions  of the fields contained in the TCB.  All offsets and 
  3845.         sizes are in bytes.
  3846.  
  3847.               Offset  Size      Definition
  3848.  
  3849.                 0       2       link to next TCB
  3850.                 4       8       null terminated task name (7 characters max)
  3851.                 14      2       task starting segment (PSP)
  3852.                 16      2       abort/suspend flags
  3853.                 18      2       current display memory segment
  3854.                 20      2       priority level (0 - 65,534)
  3855.                 22      2       time slice counter
  3856.                 26      2       suspend timer value
  3857.                 28      2       stack segment
  3858.                 30      2       stack pointer
  3859.                 32      2       display type
  3860.                 34      2       display memory
  3861.                 38      2       termination count
  3862.                 40      2       equipment flag for BIO10 driver
  3863.                 42      1       background CRT mode
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.                                      (57)
  3893.  
  3894.  
  3895.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3896.  
  3897.               Offset  Size      Definition
  3898.  
  3899.                 43      2       number of CRT columns
  3900.                 45      2       length of CRT display memory
  3901.                 47      2       segment of real CRT memory
  3902.                 49      16      8 CRT cursor positions
  3903.                 65      2       current cursor mode
  3904.                 67      1       active CRT page
  3905.                 68      2       6845 address
  3906.                 72      2       foreground task flag
  3907.                 80      2       save video memory segment
  3908.                 82      4       INT 22H context
  3909.                 86      4       INT 23H context
  3910.                 90      4       INT 24H context
  3911.                 94      2       top of memory for this task
  3912.                 100     2       DTA segment
  3913.                 102     2       DTA offset
  3914.                 108     1       current attribute (ANSI.SYS)
  3915.                 109     1       current horizontal coordinate (ANSI.SYS)
  3916.                 110     1       current vertical coordinate (ANSI.SYS)
  3917.                 111     1       current display state (ANSI.SYS)
  3918.                 112     1       maximum columns (ANSI.SYS)
  3919.                 113     1       current page (ANSI.SYS)
  3920.                 114     2       saved cursor position (ANSI.SYS)
  3921.                 116     1       parameter buffer index (ANSI.SYS)
  3922.                 117     1       current screen mode (ANSI.SYS)
  3923.                 118     1       wrap flag (ANSI.SYS)
  3924.                 119     6       parameter buffer (ANSI.SYS)
  3925.                 125     1       keyboard DSR state (ANSI.SYS)
  3926.                 126     7       keyboard DSR buffer (ANSI.SYS)
  3927.                 136     16      request header for DOS driver calls
  3928.                 166     2       segment of LIM map if LIM task
  3929.                 168     2       task makes LIM calls flag
  3930.                 170     2       LIM handle for this task
  3931.                 172     2       keyboard shift status
  3932.                 186     2       parent TCB if child process
  3933.                 188     2       termination code
  3934.                 190     2       COM port number
  3935.                 196     2       current IRQ number
  3936.                 200     2       miscellaneous flag word
  3937.                 204     4       INT 10H vector context
  3938.                 208     2       LIM alternate map set number
  3939.                 210     414     DOS current disk and directory context
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.                                      (58)
  3959.  
  3960.  
  3961.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  3962.  
  3963.         The System Block
  3964.  
  3965.         The  System Block is a data structure inside MultiDos Plus  which 
  3966.         contains   pointers   to  other  MultiDos  Plus   internal   data 
  3967.         structures.  It is used by other programs to retrieve information 
  3968.         for  debugging and setting up a display driver for BIOS interrupt 
  3969.         10H.
  3970.  
  3971.         The  pointer  to  the System Block is  obtained  by  issuing  the 
  3972.         MultiDos  Plus service interrupt with a function code of 21  (Get 
  3973.         System Block Pointer). The pointer returned points to a structure 
  3974.         of the following format:
  3975.  
  3976.               Offset  Size      Definition
  3977.  
  3978.                 0       2       segment of System Control Block
  3979.                 2       2       redirection flag set by /NOREDIRECT
  3980.                 4       2       no BIOS 10H flag set by /NO10
  3981.                 6       4       pointer to old interrupt 10H
  3982.                 10      4       pointer to new interrupt 10H
  3983.                 14      4       pointer to word with current TCB offset
  3984.                 18      4       pointer to word with Idle task TCB offset
  3985.                 22      4       pointer to word with foreground TCB offset
  3986.                 26      4       pointer to word with MultiDos Plus TCB offset
  3987.                 30      2       TCB size
  3988.                 32      2       number of TCBs
  3989.                 34      2       expanded memory present flag
  3990.                 36      2       base segment of expanded memory frame
  3991.                 38      2       size of expanded memory frame in 16K pages
  3992.                 40      2       base segment for conventional memory tasks
  3993.                 42      2       number of conventional memory paragraphs
  3994.                 44      4       pointer to list of queue pointers
  3995.  
  3996.  
  3997.  
  3998.  
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.                                      (59)
  4025.  
  4026.  
  4027.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  4028.  
  4029.         SOFTWARE INTERFACE FOR TERMINAL COMMUNICATION
  4030.         ---------------------------------------------
  4031.  
  4032.         When  a program is loaded with the COMM command option,  MultiDos 
  4033.         Plus  will direct certain keyboard and display functions  to/from 
  4034.         the  serial  communication  ports.  This  section  describes  the 
  4035.         specific  functions performed and the software interface  to  the 
  4036.         communication ports. By using this facility it is possible to run 
  4037.         many  standard  DOS programs from a  "dumb"  terminal,  including 
  4038.         COMMAND.COM.
  4039.  
  4040.         In  order  to use this feature you must install a special  driver 
  4041.         which  will  handle the low level BIOS  communication  functions.  
  4042.         This  driver  is currently not supplied  with  MultiDos  Plus;  a 
  4043.         detailed  description of the driver is provided here so that  the 
  4044.         user can develop a suitable driver. 
  4045.  
  4046.         Terminal  redirection is enabled by the COMM command described in 
  4047.         Chapter  II.  NOTE:  The communications driver must  be  resident 
  4048.         prior  to  using the command.  It may be loaded  before  MultiDos 
  4049.         Plus,  or you can have MultiDos Plus load and execute the driver. 
  4050.         The  driver  must  "hook" onto software interrupt 14H  to  handle 
  4051.         functions issued to it by MultiDos Plus.  A basic requirement  of 
  4052.         the  driver  is  that it use the hardware interrupts  to  collect 
  4053.         input  data from the communications port.  If the driver  is  not 
  4054.         interrupt driven, it will most likely function improperly because 
  4055.         the  program  was not assigned a time slice when the port  needed 
  4056.         servicing.
  4057.  
  4058.         MultiDos  Plus  interfaces  to the driver by  means  of  software 
  4059.         interrupt 14H. The function codes used by the driver are distinct 
  4060.         from the BIOS RS-232 services. 
  4061.  
  4062.         Basically,  MultiDos Plus invokes INT 14H in three places. When a 
  4063.         task  is  loaded,  INT 14H function codes 20H,  24H and  25H  are 
  4064.         issued  to initialize the specified communications port.  When  a 
  4065.         task reads from the keyboard,  INT 14H function codes 22H and 23H 
  4066.         are issued and if there is a buffer overflow,  function code  25H 
  4067.         is issued to clear the error.  Function code 27H is issued if INT 
  4068.         16H is issued to check for a key press. When a task issues an INT 
  4069.         10H function code 0EH to display a character,  the MDBIO10 driver 
  4070.         will  invoke  INT 14H function code 21H to send the character  to 
  4071.         the task's communication port.
  4072.  
  4073.         When the task is loaded, the communications port number is placed 
  4074.         in the task's TCB at offset 190.  Later read and write  functions 
  4075.         check  the TCB field to determine which communication port to use 
  4076.         for the operation.  The port number placed in the TCB is zero  if 
  4077.         no communication redirection should be done for the task.  If the 
  4078.         port is a one (1),  then COM1 is assumed. The highest port number 
  4079.         allowed depends on what is supported by the port driver.
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.                                      (60)
  4091.  
  4092.  
  4093.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  4094.  
  4095.         When the task is loaded and the port is initialized,  the INT 14H 
  4096.         functions  are  issued in the order 25H,  20H,  and then  24H  to 
  4097.         initialize the port.
  4098.  
  4099.  
  4100.         Initialize Port
  4101.         ---------------
  4102.  
  4103.         Function Code = 20H
  4104.  
  4105.         Entry:
  4106.              AH = function code (20H)
  4107.              AL = initialization parameters
  4108.              DX = port number 0 based (COM1 = 0)
  4109.         Exit:
  4110.              AH = 0H            command successful
  4111.                   41H           no port address
  4112.                   64H           monitor mode active
  4113.  
  4114.         The  RS-232 port specified in the DX register is initialized  for 
  4115.         the parameters specified in the AL register.  The bit settings in 
  4116.         AL have the following meaning:
  4117.  
  4118.              Bits       Definition
  4119.  
  4120.              5 - 7      baud rate
  4121.  
  4122.              000        110
  4123.              001        150
  4124.              010        300
  4125.              011        600
  4126.              100        1200
  4127.              101        2400
  4128.              110        4800
  4129.              111        9600
  4130.  
  4131.              3 - 4      parity
  4132.  
  4133.                00       none
  4134.                01       odd
  4135.                11       even
  4136.  
  4137.                2        stop bits
  4138.  
  4139.                0        one stop bit
  4140.                1        two stop bits
  4141.  
  4142.              0 - 1      word length
  4143.  
  4144.               10        7 bits
  4145.               11        8 bits
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.  
  4154.  
  4155.  
  4156.                                      (61)
  4157.  
  4158.  
  4159.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  4160.  
  4161.         Transmit Character
  4162.         ------------------
  4163.  
  4164.         Function Code = 21H
  4165.  
  4166.         Entry:
  4167.              AH = function code
  4168.              AL = character to send
  4169.              DX = port number
  4170.  
  4171.         Exit:
  4172.              AH =  0H   command successful
  4173.                   39H   no DSR or CTS
  4174.                   3CH   no DSR
  4175.                   3BH   no CTS
  4176.                   42H   monitor mode inactive
  4177.                   41H   invalid port address
  4178.                   97H   time-out
  4179.  
  4180.         In  order to use this function,  the monitor mode must have  been 
  4181.         activated by issuing an INT 14H function code 24H.
  4182.  
  4183.         The  character  in the AL register is sent to the  communications 
  4184.         port   as  soon  as  the  port  is  able  to  receive  data   for 
  4185.         transmission.
  4186.  
  4187.  
  4188.  
  4189.         Receive Character
  4190.         -----------------
  4191.  
  4192.         Function Code = 22H
  4193.  
  4194.         Entry:
  4195.              AH = function code
  4196.              DX = port number
  4197.  
  4198.         Exit:
  4199.              AH = 0H    command successful
  4200.                   3DH   framing and parity error
  4201.                   3EH   overrun error
  4202.                   3FH   framing error
  4203.                   40H   parity error
  4204.                   41H   invalid port number
  4205.                   42H   monitor mode not active
  4206.                   96H   ring buffer overflow
  4207.                   97H   time-out
  4208.              AL = character received
  4209.  
  4210.         The   receive  ring  buffer  is  examined  to  determine  if  any 
  4211.         characters  have been received from the  specified  communication 
  4212.         port.  If  a  character  is present,  it is returned  in  the  AL 
  4213.         register. If no characters have been received, the function waits 
  4214.         for a character until a time-out occurs. The time-out duration is 
  4215.         implementation specific.
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222.                                      (62)
  4223.  
  4224.  
  4225.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  4226.  
  4227.         Return Port Status
  4228.         ------------------
  4229.  
  4230.         Function Code = 23H
  4231.  
  4232.         Entry:
  4233.              AH = function code
  4234.              DX = port number
  4235.  
  4236.         Exit:
  4237.              AH = line status
  4238.              AL = modem status
  4239.  
  4240.         The  line  and modem status registers are read,  and  control  is 
  4241.         returned  to the caller.  The following describes the meaning  of 
  4242.         the  bit settings in the AH and AL registers.  The definition  is 
  4243.         true if the bit is set to one.
  4244.  
  4245.         LINE STATUS
  4246.  
  4247.         Bits    Definition
  4248.           7     time-out error
  4249.           6     transfer shift register
  4250.           5     transfer holding register
  4251.           4     break-detect error
  4252.           3     framing error
  4253.           2     parity error
  4254.           1     overrun error
  4255.           0     data ready
  4256.  
  4257.         MODEM STATUS
  4258.  
  4259.         Bits    Definition
  4260.           7     received line signal detect
  4261.           6     ring indicator
  4262.           5     data set ready
  4263.           4     clear to send
  4264.           3     delta receive line signal detect
  4265.           2     trailing edge ring detect
  4266.           1     delta data set ready
  4267.           0     delta clear to send
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.                                      (63)
  4289.  
  4290.  
  4291.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  4292.  
  4293.         Set Monitor Mode
  4294.         ----------------
  4295.  
  4296.         Function Code = 24H
  4297.  
  4298.         Entry:
  4299.              AH = function code
  4300.              AL = 0     no individual status
  4301.                   1     individual status
  4302.              DX = port number
  4303.  
  4304.         Exit:
  4305.              AH =       status
  4306.                    0H  successful
  4307.                   3AH  illegal value in AL
  4308.                   41H  invalid port address
  4309.                   64H  monitor mode already on
  4310.  
  4311.         This  function  sets  up  the  specified  serial  port  to  start 
  4312.         accepting  interrupts.  Any input or output buffers are  cleared. 
  4313.         The setting in register AL indicates how the port status is to be 
  4314.         maintained.  A value of 0 causes the status to be maintained as a 
  4315.         single value. A value of 1 will maintain status for every byte in 
  4316.         the receive buffer.
  4317.  
  4318.  
  4319.  
  4320.         Clear Buffers
  4321.         -------------
  4322.  
  4323.         Function Code = 25H
  4324.  
  4325.         Entry:
  4326.              AH = function code
  4327.              AL = 0     clear buffers only
  4328.                   1     clear buffers and deactivate
  4329.              DX = port number
  4330.  
  4331.         Exit:
  4332.              AH =      status
  4333.                    0H   successful
  4334.                   3AH   illegal value in AL
  4335.                   41H   invalid port number
  4336.                   42H   monitor mode off
  4337.  
  4338.         Any  buffers  associated with the port are  cleared.  If  the  AL 
  4339.         register value is one, the interrupts for the port are turned off 
  4340.         by resetting the PIC.
  4341.  
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.  
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354.                                      (64)
  4355.  
  4356.  
  4357.            *** MultiDos Plus 4.01 Copyright (c) 1991 Nanosoft Inc. ***
  4358.  
  4359.  
  4360.         Return Buffer Character Count
  4361.         -----------------------------
  4362.  
  4363.         Function Code = 27H
  4364.  
  4365.         Entry:
  4366.         AH = function code
  4367.         DX = port number
  4368.  
  4369.         Exit:
  4370.         AH = status
  4371.         0H              successful
  4372.         41H             invalid port number
  4373.         42H             monitor mode not active
  4374.         AL = number of elements in input buffer
  4375.  
  4376.         The  number of characters in the input buffer are returned in the 
  4377.         AL register. No other action is taken on the port.
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.                                      (65)
  4421.  
  4422.  
  4423.