home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK2 / SOURCE / MOVE / MOVEAPI.TX$ / MOVEAPI
Encoding:
Text File  |  1992-03-11  |  19.3 KB  |  543 lines

  1.                               MOVEAPI.TXT File
  2.  
  3.                            Release Notes for the
  4.                     Microsoft(R) Overlay Virtual Environment
  5.  
  6.                         Released with the Microsoft(R) C
  7.                   Professional Development System, Version 7.0
  8.  
  9.                   (C) Copyright Microsoft Corporation, 1991
  10.  
  11.  
  12.      This document describes advanced features of the Microsoft Overlay
  13.      Virtual Environment (MOVE). MOVE is a dynamic overlay manager
  14.      for use in creating DOS programs with overlays. MOVE is described
  15.      in the chapter called "Creating Overlaid DOS Programs" in the
  16.      "Environment and Tools" manual. This file discusses ways you can
  17.      customize your overlaid program and analyze its performance.
  18.  
  19.  
  20.  
  21. =============================< Contents >==============================
  22.  
  23.  
  24.      This file has 3 parts:
  25.  
  26.           Part     Note
  27.           ----     ----
  28.  
  29.           1        The MOVE API
  30.  
  31.           2        MOVE Environment Variables
  32.  
  33.           3        The TRACE Utility
  34.  
  35.  
  36.  
  37. =======================< Part 1: The MOVE API >========================
  38.  
  39.  
  40.      The MOVE API is provided in a library called MOVE.LIB. This
  41.      library is a component of the C combined libraries for medium and
  42.      large models. (Another form of the library, MOVETR.LIB, also
  43.      contains the MOVE API. See Part 3 below.) The MOVE API is declared
  44.      in the file MOVEAPI.H, which is available on disk. The following
  45.      sections describe the routines and functionality provided by MOVE.
  46.  
  47.  
  48.      The _moveinit function
  49.      ----------------------
  50.  
  51.      MOVE begins an overlaid program with a call to _moveinit.
  52.  
  53.      You can use the default function provided in MOVE.LIB, or you can
  54.      write your own version of _moveinit and link it to your program.
  55.      The source code for the default version of this function is
  56.      available on disk in the file MOVEINIT.C. The _moveinit function
  57.      must calculate the heap and cache needed for the overlays and
  58.      allocate memory for the heap and cache.
  59.  
  60.      The _moveinit call occurs before the call to _astart that begins a
  61.      C program and performs initialization. Because of this, do not
  62.      call C run-time routines from any version of _moveinit.
  63.  
  64.      The following functions are called from _moveinit:
  65.  
  66.           _movesetheap
  67.           _movegetcache
  68.           _movesetcache
  69.           _movetraceon (only in MOVETR.LIB)
  70.  
  71.      The functions are described in the sections below. In addition,
  72.      several variables are created by LINK and begin with $$; these
  73.      variables are described in the "LINK Variables" section below.
  74.  
  75.  
  76.      Heap allocation
  77.      ---------------
  78.  
  79.      extern unsigned short __far __cdecl _movesetheap(
  80.                                          unsigned short maxovl,
  81.                                          unsigned short minheap,
  82.                                          unsigned short reqheap );
  83.  
  84.      The _movesetheap function sets the overlay heap size.
  85.  
  86.      <maxovl>
  87.           The maximum number of overlays. The $$COVL variable always
  88.           contains this value.
  89.  
  90.      <minheap>
  91.           The minimum heap size, specified in 16-byte paragraphs. The
  92.           heap must be at least the size of the largest overlay. To
  93.           calculate overlay sizes, use $$MPOVLSIZE as in MOVEINIT.C.
  94.  
  95.      <reqheap>
  96.           The requested heap size, specified in 16-byte paragraphs. The
  97.           default _moveinit routine requests the sum of the sizes of
  98.           the three largest overlays.
  99.  
  100.      MOVE attempts to allocate the requested amount of memory. If that
  101.      much memory is not available, MOVE tries to allocate as much as
  102.      possible. If the amount of available memory is less than the
  103.      minimum heap requested, MOVE ends the program and issues a
  104.      run-time error.
  105.  
  106.  
  107.      Cache allocation
  108.      ----------------
  109.  
  110.      extern void __far __cdecl _movegetcache(
  111.                                unsigned short __far *expmem,
  112.                                unsigned short __far *extmem );
  113.  
  114.      The _movegetcache function determines the amount of memory
  115.      available for a cache.
  116.  
  117.      *<expmem>
  118.           Available expanded memory, in kilobytes.
  119.  
  120.      *<extmem>
  121.           Available extended memory, in kilobytes.
  122.  
  123.  
  124.      extern unsigned short __far __cdecl _movesetcache(
  125.                                          unsigned short expmem,
  126.                                          unsigned short extmem );
  127.  
  128.      The _movesetcache function allocates expanded and extended memory
  129.      for an overlay cache.
  130.  
  131.      <expmem>
  132.           Requested amount of expanded memory, specified in kilobytes.
  133.  
  134.      <extmem>
  135.           Requested amount of extended memory, specified in kilobytes.
  136.  
  137.  
  138.      The default _moveinit routine requests a cache equal to the sum of
  139.      all overlays. If _movesetcache cannot allocate the requested
  140.      amount of memory, it sets a bit in the return value. MOVEAPI.H
  141.      defines the following constants to represent bits in the return
  142.      value:
  143.  
  144.           __MOVESETCACHE_ERR_NO    0   No error
  145.           __MOVESETCACHE_ERR_XMS   1   Cannot allocate extended memory
  146.           __MOVESETCACHE_ERR_EMS   2   Cannot allocate expanded memory
  147.  
  148.  
  149.      The following global variables are set by _movesetcache when the
  150.      overlay cache is allocated:
  151.  
  152.           extern unsigned short __far __cdecl _moveckbxms;
  153.           extern unsigned short __far __cdecl _moveckbems;
  154.  
  155.      The _moveckbxms variable is set to the size of the allocated
  156.      extended memory. The _moveckbems variable is set to the size of
  157.      the allocated expanded memory.
  158.  
  159.  
  160.      Freeing and reallocating cache memory
  161.      -------------------------------------
  162.  
  163.      You can temporarily release and then restore the memory allocated
  164.      for the overlay cache. This is useful when your program spawns
  165.      another program that uses extended or expanded memory or when you
  166.      want to prepare for a possible abnormal exit from your program.
  167.  
  168.  
  169.      extern void __far __cdecl _movepause( void );
  170.  
  171.           The _movepause function frees the cache memory and closes the
  172.           executable file.
  173.  
  174.      extern void __far __cdecl _moveresume( void );
  175.  
  176.           The _moveresume function reallocates memory for the overlay
  177.           cache and reopens the executable file.
  178.  
  179.  
  180.      MOVEAPI.H defines the following variables for use by these
  181.      functions:
  182.  
  183.           extern unsigned short __far __cdecl _movefpause;
  184.           extern unsigned short __far __cdecl _movefpaused;
  185.  
  186.  
  187.      MOVEAPI.H also defines constants to represent bits in _movefpause
  188.      and _movefpaused, as follows:
  189.  
  190.           __MOVE_PAUSE_DISK     2    Represents the executable file
  191.           __MOVE_PAUSE_CACHE    4    Represents the cache memory
  192.  
  193.  
  194.      The _movepause function reads the value in _movefpause, and it
  195.      sets _movefpaused to the value of the action taken by _movepause.
  196.      Before you call _movepause, set _movefpause to __MOVE_PAUSE_DISK
  197.      to close the file, and set it to __MOVE_PAUSE_CACHE to free the
  198.      cache, as in:
  199.  
  200.           _movefpause |= __MOVE_PAUSE_DISK;
  201.           _movefpause |= __MOVE_PAUSE_CACHE;
  202.           _movepause();
  203.  
  204.  
  205.      The _moveresume function reads the value in _movefpaused, then it
  206.      clears _movefpaused. The overlays that were in the heap and cache
  207.      are not restored. Therefore, after a call to _moveresume, the
  208.      program may at first run slightly more slowly as it makes calls to
  209.      routines in overlays.
  210.  
  211.  
  212.      LINK Variables
  213.      --------------
  214.  
  215.      The following variables are created by LINK:
  216.  
  217.      $$MAIN
  218.           Entry point to an overlaid program.  In a C program, this is
  219.           defined to be __astart.
  220.  
  221.      $$CGSN
  222.           Number of global segments. Each object file contributing to
  223.           an overlay takes up one global segment number (GSN). Each
  224.           COMDAT (packaged-function) segment takes up one GSN.
  225.  
  226.      $$COVL
  227.           Number of overlays. Each overlay can contain several GSNs.
  228.  
  229.      $$MPGSNBASE
  230.           Map of GSNs to segment displacements in an overlay.
  231.  
  232.      $$MPGSNOVL
  233.           Map of GSNs to overlay numbers.
  234.  
  235.      $$MPOVLLFA
  236.           Map of overlay numbers to logical file addresses of overlays
  237.           in the executable file.
  238.  
  239.      $$MPOVLSIZE
  240.           Map of overlay numbers to overlay image sizes (the size of
  241.           the code actually loaded into the overlay heap).
  242.  
  243.      $$INTNO
  244.           Overlay interrupt number.
  245.  
  246.  
  247.  
  248. ================< Part 2: MOVE Environment Variables >=================
  249.  
  250.  
  251.      You can use environment variables at run time to specify the size
  252.      of the requested overlay heap and overlay cache and the maximum
  253.      number of overlays. The _moveinit function given in MOVEINIT.C
  254.      provides environment support; you can compile this function and
  255.      link it with your program. (MOVETR.LIB contains a version of
  256.      _moveinit that already contains environment support.)
  257.  
  258.      First, enable environment support by compiling MOVEINIT.C with
  259.      MOVE_ENV defined. Then specify the resulting MOVEINIT.OBJ when
  260.      linking your program. With MOVE_ENV defined, MOVEAPI.H declares
  261.      the following variable:
  262.  
  263.           extern unsigned short __far __cdecl _movesegenv;
  264.  
  265.      Compiling for environment support causes MOVEINIT.C to define a
  266.      function called _movegetenv. The environment-support version of
  267.      _moveinit uses _movegetenv to get the values of the following
  268.      environment variables:
  269.  
  270.           MOVE_HEAP     Requested heap (paragraphs)
  271.           MOVE_COVL     Maximum number of overlays
  272.           MOVE_EMS      Requested expanded-memory cache (paragraphs)
  273.           MOVE_XMS      Requested extended-memory cache (paragraphs)
  274.  
  275.      To use these variables, set them to strings that represent the
  276.      desired settings. Each string must consist of exactly four
  277.      hexadecimal digits.
  278.  
  279.  
  280.  
  281. =====================< Part 3: The TRACE Utility >=====================
  282.  
  283.  
  284.      You can optimize the overlays in your program with the help of the
  285.      tracing form of the MOVE library (MOVETR.LIB) and the Microsoft
  286.      MOVE Trace Utility (TRACE) version 1.00. MOVETR.LIB contains
  287.      MOVE.LIB and additional routines for use in tracing overlay
  288.      behavior.
  289.  
  290.      Create a tracing version of your program as described in the
  291.      following sections. When you run your program, the tracing
  292.      functions create a binary file called MOVE.TRC in the directory
  293.      from which the program is run. After your program ends, use TRACE
  294.      to read MOVE.TRC. If the tracing results show you that some
  295.      functions cause overlays to be swapped frequently, you can
  296.      reorganize the functions in the overlays by using statements in
  297.      the module-definition file.
  298.  
  299.  
  300.      Creating a Tracing Version of an Overlaid Program
  301.      ------------------------------------------------------
  302.  
  303.      To create a program that will trace overlay performance, specify
  304.      MOVETR.LIB in LINK's <libraries> field. This causes LINK to use
  305.      the MOVETR.LIB library instead of the MOVE.LIB component of the
  306.      default combined library. Use LINK's /NOE option to prevent
  307.      conflicts between MOVETR.LIB and the combined library. If you
  308.      explicitly specify the combined library in the <libraries> field,
  309.      list MOVETR.LIB before the combined library.
  310.  
  311.  
  312.      The Trace Functions
  313.      ------------------
  314.  
  315.      By default, tracing is in effect during the entire run of your
  316.      program. You do not need to make any changes in your program to
  317.      enable tracing. However, MOVETR.LIB provides two functions that
  318.      you can use to turn tracing on and off within your program:
  319.  
  320.      extern void __far __cdecl _movetraceon( void );
  321.  
  322.           Turns on tracing. This function opens the file MOVE.TRC and
  323.           activates tracing. During tracing, information about overlay
  324.           behavior is written to MOVE.TRC. The default _moveinit
  325.           function calls _movetraceon at the start of the program if
  326.           MOVE_PROF is defined; this definition is in MOVETR.LIB.
  327.  
  328.      extern void __far __cdecl _movetraceoff( void );
  329.  
  330.           Turn off tracing and closes MOVE.TRC.
  331.  
  332.      The tracing functions are declared in MOVEAPI.H. They are defined
  333.      only in MOVETR.LIB.
  334.  
  335.  
  336.      Running TRACE
  337.      -------------
  338.  
  339.      To run TRACE, use the following syntax:
  340.  
  341.           TRACE [options] [tracefile]
  342.  
  343.      The <tracefile> is the MOVE.TRC file created during a tracing
  344.      session. You can specify a path with the filename. If <tracefile>
  345.      is not specified, TRACE looks in the current directory for a file
  346.      called MOVE.TRC.
  347.  
  348.      An option is preceded by an option specifier, either a forward
  349.      slash (/) or a dash (-). Options are not case sensitive. An option
  350.      can be abbreviated to its initial letter. Options can appear
  351.      anywhere on the command line.
  352.  
  353.      /SUM
  354.           Displays a summary of the program's performance. If /SUM is
  355.           not specified, TRACE displays the entire tracing session. For
  356.           details, see "TRACE Performance Summary" below. If /SUM is
  357.           specified, /EXE and /MAP have no effect.
  358.  
  359.      /EXE:filename
  360.           Allows TRACE to read the executable file that was traced and
  361.           extract function names for use in the trace output. Specify
  362.           the filename of the executable file that generated the
  363.           MOVE.TRC file. You can specify a path with the filename. If
  364.           /EXE is not specified, the trace output refers to functions
  365.           by overlay number and offset.
  366.  
  367.           The program must contain Micrososft Symbolic Debugging
  368.           Information that is compatible with Microsoft CodeView
  369.           version 4.00. To include debugging information, create the
  370.           object file using the /Zi option and link the program using
  371.           the /CO option.
  372.  
  373.      /HELP
  374.           Displays a usage statement.
  375.  
  376.      /?
  377.           Displays a usage statement.
  378.  
  379.  
  380.      TRACE Output
  381.      ------------
  382.  
  383.      TRACE displays information on the tracing session to the standard
  384.      output device. You can use the redirection operator (>) to save
  385.      the output in a file. The output is in table format. Each line of
  386.      output represents an interoverlay transaction. A line of
  387.      information is organized into the following fields:
  388.  
  389.         - The overlay to which to return from the current transaction
  390.           (If blank, the overlay in the previous line is implied.)
  391.  
  392.         - The physical return address in segment:offset form
  393.           (If blank, the address in the previous line is implied.)
  394.  
  395.         - The transaction type, which is one of the following:
  396.  
  397.              - Present
  398.              - Load from disk
  399.              - Load from expanded memory
  400.              - Load from extended memory
  401.              - Discard from heap
  402.              - Cache to expanded memory
  403.              - Cache to extended memory
  404.              - Discard from cache
  405.              - Invalid
  406.  
  407.         - The overlay that is the object of the transaction
  408.  
  409.         - The segment in memory where the transaction overlay is loaded
  410.  
  411.         - The interoverlay operation, which is one of the following:
  412.  
  413.              - Call <function>, in which <function> is:
  414.                   - An overlay number and an offset in default output
  415.                   - A function name if /EXE is used
  416.                   - A decorated function name if /EXE and /MAP are used
  417.  
  418.              - Return
  419.  
  420.              - If blank, the Call in the previous line is implied.
  421.  
  422.  
  423.      TRACE Performance Summary
  424.      -------------------------
  425.  
  426.      When you run TRACE with the /SUM option, TRACE displays a summary
  427.      of overlay performance to the standard output device. The full
  428.      session is not displayed. You can use the redirection operator (>)
  429.      to save the output in a file. The summary information is organized
  430.      into the following fields:
  431.  
  432.           OVERALL
  433.           -------
  434.  
  435.           calls
  436.                Sum of "Call" operations
  437.  
  438.           returns
  439.                Sum of "Return" operations
  440.  
  441.           HEAP
  442.           ----
  443.  
  444.           discards
  445.                Sum of "Discard from heap" transactions
  446.  
  447.           discards / entries
  448.                Discards as percent of (calls + returns)
  449.  
  450.           loads from disk
  451.                Sum of "Load from disk" transactions
  452.  
  453.           loads from expanded memory
  454.                Sum of "Load from expanded memory" transactions
  455.  
  456.           loads from extended memory
  457.                Sum of "Load from extended memory" transactions
  458.  
  459.           CACHE
  460.           -----
  461.  
  462.           discards
  463.                Sum of "Discard from cache" transactions
  464.  
  465.           discards / entries
  466.                Discards as percent of (calls + returns)
  467.  
  468.           caches to expanded memory
  469.                Sum of "Cache to expanded memory" transactions
  470.  
  471.           caches to extended memory
  472.                Sum of "Cache to extended memory" transactions
  473.  
  474.  
  475.      TRACE Errors
  476.      ------------
  477.  
  478.      This section describes the errors and warnings issued by TRACE.
  479.  
  480.  
  481.      TR1001    invalid filename for /EXE
  482.  
  483.                The string specified with the /EXE option was not a
  484.                valid filename.
  485.  
  486.      TR1005    missing filename for /EXE
  487.  
  488.                The /EXE option must be followed by a colon and a
  489.                filename, with no spaces in between.
  490.  
  491.      TR1007    unrecognized option
  492.  
  493.                The command line contained an option specifier, either
  494.                a forward slash (/) or a dash (-), but the string that
  495.                followed was not recognized as a TRACE option.
  496.  
  497.      TR1010    cannot find trace file
  498.  
  499.                One of the following occurred:
  500.  
  501.                   - A trace file was specified on the command line,
  502.                     but the specified file does not exist.
  503.  
  504.                   - No trace file was specified on the command line
  505.                     and TRACE assumed a trace file called MOVE.TRC,
  506.                     but MOVE.TRC does not exist.
  507.  
  508.  
  509.      TR1011    error opening/reading .EXE file
  510.  
  511.                TRACE either failed to find the executable file
  512.                specified with /EXE or encountered an error while
  513.                opening the file.
  514.  
  515.      TR1012    out of memory
  516.  
  517.                The available memory is insufficient for the size of the
  518.                program being traced.
  519.  
  520.      TR1013    invalid debugging information
  521.  
  522.                The debugging information contained in the executable
  523.                file was not packed using CVPACK 4.00.
  524.  
  525.      TR4001    cannot find function name
  526.  
  527.                TRACE could not find a function name in order to display
  528.                it. TRACE continued to generate output, but the function
  529.                name was missing from the output.
  530.  
  531.                Function names are displayed when the /EXE option is
  532.                specified. Either the executable file contains corrupt
  533.                debugging information or a module in the executable file
  534.                was compiled without the /Zi option for including
  535.                debugging information.
  536.  
  537.      TR4002    missing debugging information for module
  538.  
  539.                TRACE could not find a symbol to correspond to a given
  540.                physical address. Probably a module was compiled without
  541.                the /Zi option for including debugging information.
  542.  
  543.