HP 3000 Manuals

Run-Time Stack [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation


HP Transact Reference Manual

Run-Time Stack 

The size and composition of the run-time stack vary with:

   *   VPLUS utilization

   *   Number and size of program segments

   *   Design of subprograms and whether swapping is used during
       processing

   *   Transact processor register utilization

Figure C-1  provides a profile of the data stack, including a
breakdown of the table register components.  The stack profile describes
a single-segment program, but it illustrates components that can occur on
the data stack regardless of program structure.

Use test mode 4 initially to determine the stack requirements of your
program or portions of it.  Use the information provided below for
individual components to change their size selectively, if desired.

The data stack components are defined as follows:

   *   PCBX: Process Control Block Extension is a control area for MPE.
       The size of this area is operating-system dependent, but can be
       reduced slightly by running Transact with the NOCB option.  Use
       this option to avoid stack overflow only on a short-term basis.
       In the long run, applications should be structured and optimized
       so that it is not necessary to use the NOCB option.

   *   VPLUS INFO: This area appears on the data stack if your Transact
       program uses VPLUS forms files.  This area is used by the VPLUS
       subsystem.  You can use fast forms files to minimize the size of
       this area.

   *   Transact OUTER BLOCK and Transact PROCESSOR CONTROL BLOCK: These
       areas contain data and pointers for Transact processor control.
       The size of these areas depends on the version and the
       installation.

   *   DATA REGISTER: The Transact data register.  (See Chapter 4 for an
       explanation of how this register works.)  The default size of this
       area is 1024 words.  The data-length parameter of the DATA= option
       in the SYSTEM statement can be used to control the size of this
       area.  Use test mode 3 or 102 to determine which values to specify
       for the DATA= option.  The data register for multiple-segment
       programs or programs using CALLs must be large enough to
       accommodate all segments or subprograms.  If one part of the
       application requires much more data register space than any other
       part, invoke it using MPE's process handling feature.

       +--------------------------+
       |                          |
       |           PCBX           |
       |                          |
       |--------------------------| <-- DL
       |                          |
       |        VPLUS INFO        |
       |                          |
       |--------------------------| <-- DB       /--> +-------------------------+
       |   Transact OUTER BLOCK   |            /      |                         |
       |--------------------------| <-- Q    /        |           BASES         |
       |   Transact PROCESSOR     |         |         |-------------------------|
       |      CONTROL BLOCK       |         |         |   VPLUS COMAREA; VPLUS, |
       |--------------------------|         |         |   KSAM, MPE, AND DATA   |
       |                          |         |         |     SET FILE INFO       |
       |      DATA REGISTER       |         |         |-------------------------|
       |--------------------------|         |         |         PROCEDURES      |
       |                          |         |         |-------------------------|
       |       TABLE REGISTER     |-------->|         |          COMMANDS       |
       |                          |         |         |-------------------------|
       |--------------------------|         |         |        SUBCOMMANDS      |
      *|       TABLE INDEX        |         |         |-------------------------|
       |--------------------------|         |         |                         |
      *|       TABLE LENGTH       |         |         |           ITEMS         |
       |--------------------------|         |         |                         |
       |                          |         |         |-------------------------|
       |       CODE REGISTER      |         |         |                         |
       |                          |         |         |       TEXT STRINGS      |
       |--------------------------|         |         |                         |
     **|      ITEM REGISTER       |         |         |-------------------------|
       |--------------------------|         |         |                         |
     **|      DATA INDEX          |         |         |      CONTROL STRINGS    |
       |--------------------------|         |         |                         |
     **|      DATA LENGTH         |         |         |-------------------------|
       |--------------------------|         |         |                         |
       |                          |          \        |         WORK SPACE      |
       ~                          ~            \      |                         |
       |                          | <-- S        \--> +-------------------------+
       ~                          ~
       +--------------------------+ <-- Z

     COMPONENTS IN THE DATA STACK                   ENTITIES IN TABLE COMPONENTS

      * Used to manage the TABLE REGISTER
     ** Used to manage the DATA REGISTER

          Figure C-1.  Data Stack Layout for a Single-Segment Transact Program 

   *   TABLE REGISTER: This is an area used to manage files, PROC calls,
       built-in and programmer-defined commands, sub-commands, and data
       items and strings.  This register's entities are identified in the
       right-hand diagram of Figure C-1 .  These entities are defined
       and ways to optimize them are suggested later in this section.

       VPLUS forms files significantly affect the size of the TABLE
       REGISTER. If an application requires many VPLUS forms, you can
       conserve stack space by doing any of the following:

          *   using a CALL structure rather than a multiple-segment
              program structure.

          *   specifying only forms used by the main program and each
              subprogram in the SYSTEM statement of the main program and
              each subprogram.  If only a forms file name is specified in
              a SYSTEM statement, Transact allocates TABLE REGISTER space
              for each form in the file and for all items associated with
              each form.

   *   TABLE INDEX and TABLE LENGTH: These areas are used to manage the
       TABLE REGISTER component.  These areas consist of indexes and
       lengths, respectively, that correspond to entities of the TABLE
       REGISTER.

   *   CODE REGISTER: An area that contains p-code data.

   *   ITEM REGISTER, DATA INDEX, and DATA LENGTH: Areas used to manage
       the DATA REGISTER component.  Each of these areas has a default
       size of 128 words.  You can use the DATA= option of the SYSTEM
       statement to control the size of these areas.  Use test mode 3 or
       102 to determine which value to specify in the data-count 
       parameter of the DATA= option.

   *   DL, DB, Q, S, and Z: These are stack pointers.  Transact requires
       4K of the space between DATA LENGTH and S. The stack requirements
       of SORT, HP2680, and other subsystems lie between S and Z. Use
       test mode 4 to locate stack pointers DL, Q, S, and Z for various
       portions of your program.

   *   The TABLE REGISTER, TABLE INDEX, and TABLE LENGTH components
       manage the following entities.  In general, as the number of these
       entities used by your Transact program increases, so does the
       table register space required:

          *   BASES: databases.

          *   VPLUS COMAREA; VPLUS, KSAM, MPE, AND DATA SET FILE INFO:
              forms files, forms, MPE and KSAM files, and data sets.

          *   PROCEDURES: calls to user procedures or system intrinsics.

          *   COMMANDS: built-in commands and command qualifiers.  The 11
              built-in commands (for example, PRINT, SORT, REPEAT, and
              EXIT) require 65 words of stack space.  Programmer-defined
              commands increase these needs.

          *   SUBCOMMANDS: programmer-defined subcommands.

          *   ITEMS: data items defined with the DEFINE statement or
              defined in the data dictionary.  You can optimize this area
              by using the DEFINE(ITEM) statement with the OPT option as
              well as by compiling with OPT@, OPTE, OPTH, OPTI or OPTP
              compiler options.  Space is allocated for all data item
              textual names and any edit masks, headings, and
              entry/prompt texts found in the data dictionary, unless
              these options are invoked.  See syntax option 3 under
              DEFINE in Chapter 8 and OPTI in Chapter 9.

          *   TEXT STRINGS: literal ASCII strings.  The stack
              requirements increase with the number of MOVE and DISPLAY
              statements with literals, WINDOW= options for VPLUS, and so
              on.  You can optimize the TEXT STRINGS component by keeping
              all application messages in a message file instead of
              embedding them in the p-code.  This practice both saves
              stack space and allows for easy message customization.
              Also consider keeping messages in forms files instead of
              using the WINDOW= option of the VPLUS verbs.

   *   CONTROL STRINGS: internal representations of DISPLAY and FORMAT
       statements and complex arithmetic expressions.

   *   WORK SPACE: work area used for sort items and match, update,
       input, key, and argument registers.  By default, 256 words are
       allocated for the work space portion of the TABLE REGISTER and 64
       words for the work space portions of the TABLE INDEX and TABLE
       LENGTH components.

       The WORK= option of the SYSTEM statement can be used to control
       the size of the work space areas.  Run test mode 3 or 102 to
       determine the requirements for your program.  To override the
       defaults, specify a work-length value for the work space portion
       of the TABLE REGISTER and a work-count value for the work space
       portions of the INDEX and TABLE LENGTH registers.

       Do not underestimate WORK SPACE requirements, because the recovery
       procedure invoked to re-use work spaces increases processing time.
       Maximize the usefulness of test mode 3 or 102 results by ensuring
       that all program options and branches are exercised several times.

Multiple-segment programs and programs using the CALL statement have
additional data stack components:

   *   Multiple-segment programs use the data stack for keeping track of
       where the segments are located on disk and for storing segment
       offsets.  Code registers for a root segment and the current
       segment are also required.

   *   Programs containing CALLs without the SWAP option use the data
       stack to control both the main program and the current subprogram.

   *   Programs containing CALLs that use the SWAP option require data
       stack components very similar to those that do not use this
       option, but they do not all need to be present simultaneously on
       the stack.

Although these three structures require additional data stack components,
they require less total stack space than a single-segment program if they
contain more than two segments.  The data stack requirements of each
structure are described in detail later in this section.


NOTE Under some circumstances, the error messages "FSERR 74" or "Items not found in dictionary" may be issued when there is no stack overflow and the items do in fact exist in the dictionary. In this context, both of these errors may be due to segmentation problems. To overcome this problem in Transact/V, try compiling with the Transact/V NOCB and STACK = 2000 or use the OPT@ option. If none of these solutions work, you will have to segment your program further and try again.
Compiler Statistics Figure C-2 shows the compiler listing that is produced when the statistics option is in effect during compilation. The format shown is for single-segment programs, but is virtually the same for the other three structures being examined in this appendix. The fields are defined as follows: COMPILE TIME STATISTICS STACK= x The number of words the Transact compiler put on its data stack during compilation. TABLE= x The portion of the data stack used for table space during compilation, in words. RUN TIME STATISTICS PCODE= x The number of words of p-code data in the current segment, plus each segment compiled before it. SCODE= x The number of words of p-code for a particular segment, main program, or subprogram. PARTIAL TABLE REGISTER BASE= x, y The number of words that the TABLE REGISTER, the TABLE FILE= x, y INDEX, and the TABLE LENGTH components require. Refer SET= x, y to Figure C-3 to map these compiler notations to the PROC= x, y entities in these components. Note that the x values $$CMD= x, y pertain to TABLE INDEX and TABLE LENGTH and that $CMD= x, y the y values pertain to TABLE REGISTER. ITEM= x, y STRNG= x, y CNTRL= x, y ------ x, y The total number of words in the PARTIAL TABLE REG. SUMMARY. FINAL TABLE REG. SUMMARY WORK AREA= x, y The number of words in the WORK SPACE portions of the TABLE REGISTER, TABLE INDEX, and TABLE LENGTH components. The x value reflects the work space in the TABLE INDEX and TABLE LENGTH components, and the y value reflects the work space in the TABLE REGISTER. TABLE REG.= y The total number of words that the TABLE REGISTER occupies. This value is the sum of the y values in the PARTIAL TABLE REG. SUMMARY and the y value in WORK AREA. TABLE INDX= x The total number of words that the TABLE INDEX requires. This value is the sum of the x values in the PARTIAL TABLE REG. SUMMARY and the x value in WORK AREA. TABLE LEN.= x The total number of words that the TABLE LENGTH needs. This value is the same as that for TABLE INDX=. RUN TIME STACK SUMMARY DATA REG.= x The number of words in the DATA REGISTER component. TABLE REG.= x The number of words in the TABLE REGISTER component. TABLE INDX= x The number of words in the TABLE INDEX component. TABLE LEN.= x The number of words in the TABLE LENGTH component. ROOT SEG.= x The number of words in the CODE REGISTER component. ITEM REG.= x The number of words in the ITEM REGISTER component. DATA INDEX= x The number of words in the DATA INDEX component. DATA LEN.= x The number of words in the DATA LENGTH component. ------ x The total number of words in the RUN TIME STACK SUMMARY. The following differences in format occur if the program is a multiple-segment program or if it uses CALLs: * For multiple-segment programs, the listing includes a PARTIAL TABLE REG. SUMMARY for each segment. The FINAL TABLE REG. SUMMARY and the RUN TIME STACK SUMMARY contain information that applies to the largest segment. * For programs using the CALL statement with or without the SWAP option, the information shown in Figure C-2 is provided for the main program compilation and for each subprogram compilation. *****COMPILE TIME STATISTICS**** STACK= x TABLE= x *******RUN TIME STATISTICS****** PCODE= x SCODE= x ***PARTIAL TABLE REG. SUMMARY*** BASE= x, y FILE= x, y SET= x, y PROC= x, y $$CMD= x, y $CMD= x, y ITEM= x, y STRNG= x, y CNTRL= x, y ------------ x, y ****FINAL TABLE REG. SUMMARY**** WORK AREA= x, y ------------ TABLE REG.= y TABLE INDX= x TABLE LEN.= x *****RUN TIME STACK SUMMARY***** DATA REG.= x TABLE REG.= x TABLE INDX= x TABLE LEN.= x ROOT SEG.= x ITEM REG.= x DATA INDEX= x DATA LEN.= x ------------ x CODE FILE STATUS: REPLACED 0 COMPILATION ERRORS PROCESSOR TIME=xx:xx:xx ELAPSED TIME=xx:xx:xx Figure C-2. Transact Compiler Statistics +----------------------+ +----TABLE INDEX and TABLE | | | LENGTH entities | PCBX | | | | | +--TABLE REGISTER entities |----------------------| | | | | | | | VPLUS INFO | v v | | |----------------------| +-------------------------+ | Transact OUTER BLOCK | | | |----------------------| BASE=x,y| BASES | | Transact PROCESSOR | |-------------------------| | CONTROL BLOCK | | VPLUS COMAREA; VPLUS, | |----------------------| FILE=x,y| KSAM, MPE, AND DATA | | | SET=x,y| SET FILE INFO | * | DATA REGISTER |DATA REG.=x |-------------------------| |----------------------| PROC=x,y| PROCEDURES | | | |-------------------------| | TABLE REGISTER | $$CMD=x,y| COMMANDS | | |TABLE REG.=x |-------------------------| |----------------------| $CMD=x,y| SUBCOMMANDS | **| TABLE INDEX |TABLE INDX=x |-------------------------| |----------------------| | | **| TABLE LENGTH |TABLE LEN.=x | ITEMS | |----------------------| ITEM=x,y| | | | |-------------------------| | CODE REGISTER |ROOT SEG.=x | | | | STRNG=x,y| TEXT STRINGS | |----------------------| | | *| ITEM REGISTER |ITEM REG.=x |-------------------------| |----------------------| | | *| DATA INDEX |DATA INDEX=x | CONTROL STRINGS | |----------------------| CNTRL=x,y| | *| DATA LENGTH |DATA LEN.=x |-------------------------| |----------------------| | | | | WORK AREA=x,y| WORK SPACE |** ~ ~ | | | | +-------------------------+ ~ ~ +----------------------+ COMPONENTS IN THE DATA STACK ENTITIES IN TABLE COMPONENTS * Can be changed by using the DATA= option of the SYSTEM statement ** Can be changed by using the WORK= option of the SYSTEM statement Figure C-3. Compiler Statistics Fields and Data Stack Components Single-Segment Programs Single-segment programs generally execute faster than multiple-segment programs because the processor does not have to overlay information on the data stack when switching from segment to segment. Figure C-4 shows the compiler listing produced when a single-segment program was compiled with the STAT option. Figure C-5 and Figure C-6 map the compiler statistics to individual components and entities in the run-time data stack. *****COMPILE TIME STATISTICS**** STACK= 23368 TABLE= 14482 *******RUN TIME STATISTICS****** PCODE= 0 SCODE= 3765 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 38, 544 SET= 12, 176 PROC= 0, 0 $$CMD= 11, 65 $CMD= 0, 0 ITEM= 82, 1047 STRNG= 195, 2192 CNTRL= 116, 916 ------------ 455, 4950 ****FINAL TABLE REG. SUMMARY**** WORK AREA= 30, 100 ------------ TABLE REG.= 5050 TABLE INDX= 485 TABLE LEN.= 485 *****RUN TIME STACK SUMMARY***** DATA REG.= 200 TABLE REG.= 5050 TABLE INDX= 485 TABLE LEN.= 485 ROOT SEG.= 3765 ITEM REG.= 30 DATA INDEX= 30 DATA LEN.= 30 ------------ 10075 CODE FILE STATUS: REPLACED 0 COMPILATION ERRORS PROCESSOR TIME=00:01:43 ELAPSED TIME=00:02:15 Figure C-4. Compiler Statistics for a Single-Segment Program +--------------------------+ | | | PCBX | | | |--------------------------| | | | VPLUS INFO | | | |--------------------------| | Transact OUTER BLOCK | 66 words |--------------------------| | Transact PROCESSOR | | CONTROL BLOCK | 816 words |--------------------------| | | | DATA REGISTER |DATA REG.= 200 words |--------------------------| | | | TABLE REGISTER |TABLE REG.= 5050 words -- | | \ |--------------------------| \ | TABLE INDEX |TABLE INDX= 485 words ---- \---see figure C-6 |--------------------------| / | TABLE LENGTH |TABLE LEN.= 485 words ---/ |--------------------------| | | | CODE REGISTER |ROOT SEG.= 3765 words | | |--------------------------| | ITEM REGISTER |ITEM REG.= 30 words |--------------------------| | DATA INDEX |DATA INDEX= 30 words |--------------------------| | DATA LENGTH |DATA LEN.= 30 words +--------------------------+ | | ~ ~ | | ~ ~ +--------------------------+ ----------- Approx. total data stack = 10957 words Figure C-5. Data Stack of a Single-Segment Program +-------------------------+ | | | BASES | BASE= 1, 10 words | | |-------------------------| | VPLUS COMAREA; VPLUS, | FILE= 38, 544 words | KSAM, MPE, AND DATA | | SET FILE INFO | SET= 12, 176 words |-------------------------| | PROCEDURES | PROC= 0, 0 words |-------------------------| | COMMANDS | $$CMD= 11, 65 words |-------------------------| | SUBCOMMANDS | $CMD= 0, 0 words |-------------------------| | | | ITEMS | ITEM= 82, 1047 words | | |-------------------------| | | | TEXT STRINGS | STRNG= 195, 2192 words | | |-------------------------| | | | CONTROL STRINGS | CNTRL= 116, 916 words | | |-------------------------| | | | WORK SPACE | WORK AREA= 30, 100 words | | | | ^ ^ +-------------------------+ | | | | TABLE INDEX and TABLE LENGTH entities--------------------+ | | TABLE REGISTER entities-------------------------+ Figure C-6. Table Register Entities of a Single-Segment Program Multiple-Segment Programs You can optimize your data stack requirements by segmenting your Transact program. The root segment and a current segment are always represented on the data stack. The savings in data stack space is approximately equal to the size of the segments not loaded. Although some processor time is required to overlay segments onto the data stack as they are required, the efficiency gained by decreasing the size of the data stack can be significant. Keeping applications functionally divided into segments minimizes segment switching. The compiler listing for a multiple-segment version of the single-segment program discussed earlier is shown in Figure C-7 . The program consists of four segments, each of which has compiler statistics in the following categories: COMPILE TIME STATISTICS RUN TIME STATISTICS PARTIAL TABLE REG. SUMMARY The FINAL TABLE REG. SUMMARY and the RUN TIME STACK SUMMARY reflect information for the largest segment, in this case segment 4. The following fields in the RUN TIME STACK SUMMARY are of special note: SEG. TABLE= Areas of the data stack used to keep track of where XFER TABLE= segments are located. The number of words required for SEG. TABLE= is version-dependent. XFER TABLE= contains 2 words for each label defined with a DEFINE(ENTRY) statement. ROOT SEG.= The number of words that the code register requires for the root segment. Keep this segment as small as possible, since it is always memory-resident. SCODE REG.= The number of words that the code register requires for the largest segment. Because the largest segment influences the number of words allocated for the data stack, try to make your segments as uniform in size as possible. Figure C-8 and Figure C-9 show how the compiler statistics map to the run-time data stack. SEGMENT 0 STATISTICS: STACK= 11210 TABLE= 3138 *******RUN TIME STATISTICS****** PCODE= 46 SCODE= 46 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 38, 544 SET= 0, 0 PROC= 0, 0 $$CMD= 0, 0 $CMD= 0, 0 ITEM= 54, 675 STRNG= 28, 154 CNTRL= 67, 303 ------------ 188, 1686 COMPILED SEGMENT 0 SEGMENT 1 STATISTICS: STACK= 12683 TABLE= 4624 *******RUN TIME STATISTICS****** PCODE= 632 SCODE= 586 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 38, 544 SET= 6, 87 PROC= 0, 0 $$CMD= 0, 0 $CMD= 0, 0 ITEM= 54, 675 STRNG= 42, 477 CNTRL= 67, 303 ------------ 208, 2096 COMPILED SEGMENT 1 Figure C-7. Compiler Statistics for a Multiple-Segment Program (1 of 3) SEGMENT 2 STATISTICS: STACK= 15623 TABLE= 6419 *******RUN TIME STATISTICS****** PCODE= 1676 SCODE= 1044 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 38, 544 SET= 7, 103 PROC= 0, 0 $$CMD= 0, 0 $CMD= 0, 0 ITEM= 61, 769 STRNG= 76, 612 CNTRL= 67, 303 ------------ 250, 2341 COMPILED SEGMENT 2 SEGMENT 3 STATISTICS: STACK= 15644 TABLE= 7392 *******RUN TIME STATISTICS****** PCODE= 3123 SCODE= 1447 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 38, 544 SET= 12, 176 PROC= 0, 0 $$CMD= 0, 0 $CMD= 0, 0 ITEM= 55, 685 STRNG= 77, 869 CNTRL= 68, 308 ------------ 251, 2592 COMPILED SEGMENT 3 Figure C-7. Compiler Statistics for a Multiple-Segment Program (2 of 3) SEGMENT 4 STATISTICS: STACK= 15738 TABLE= 7134 *******RUN TIME STATISTICS****** PCODE= 3773 SCODE= 650 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 38, 544 SET= 12, 176 PROC= 0, 0 $$CMD= 11, 65 $CMD= 0, 0 ITEM= 74, 943 STRNG= 110, 865 CNTRL= 115, 911 ------------ 361, 3514 COMPILED SEGMENT 4 ****FINAL TABLE REG. SUMMARY**** WORK AREA= 30, 100 ------------ TABLE REG.= 3614 TABLE INDX= 391 TABLE LEN.= 391 *****RUN TIME STACK SUMMARY***** DATA REG.= 200 SEG. TABLE= 128 TABLE REG.= 3614 TABLE INDX= 391 TABLE LEN.= 391 ROOT SEG.= 46 XFER TABLE= 8 SCODE REG.= 1447 ITEM REG.= 30 DATA INDEX= 30 DATA LEN.= 30 ------------ 6315 CODE FILE STATUS: REPLACED 0 COMPILATION ERRORS PROCESSOR TIME=00:01:41 Figure C-7. Compiler Statistics for a Multiple-Segment Program (3 of 3) |--------------------------| | PCBX | | | |--------------------------| | | | VPLUS INFO | |--------------------------| | Transact OUTER BLOCK | 66 words |--------------------------| | Transact PROCESSOR | | CONTROL BLOCK | 816 words |--------------------------| | | | DATA REGISTER |DATA REG.= 200 words |--------------------------| | DISC ADDRESS SEG. TABLE |SEG. TABLE= 128 words |--------------------------| | | | TABLE REGISTER |TABLE REG.= 3614 words --\ | | \ |--------------------------| \ | TABLE INDEX |TABLE INDX= 391 words -----\--see Figure C-9 |--------------------------| / | TABLE LENGTH |TABLE LEN.= 391 words ----/ |--------------------------| | CODE REGISTER | | (Root Segment) |ROOT SEG.= 46 words |--------------------------| | TRANSFER TABLE |XFER TABLE= 8 words |--------------------------| | CODE REGISTER | | (SCODE - Overlay Area) |SCODE REG.= 1447 words |--------------------------| | ITEM REGISTER |ITEM REG.= 30 words |--------------------------| | DATA INDEX |DATA INDEX= 30 words |--------------------------| | DATA LENGTH |DATA LEN.= 30 words |--------------------------| ~ ~ | | ~ ~ +--------------------------+ ------------ Approx. total data stack = 7197 words Figure C-8. Data Stack of a Multiple-Segment Program |-------------------------| | | | BASES | BASE= 1, 10 words | | |-------------------------| | VPLUS COMAREA; VPLUS, | FILE= 38, 544 words | KSAM, MPE, AND DATA | | SET FILE INFO | SET= 12, 176 words |-------------------------| | PROCEDURES | PROC= 0, 0 words |-------------------------| | COMMANDS | $$CMD= 11, 65 words |-------------------------| | SUBCOMMANDS | $CMD= 0, 0 words |-------------------------| | | | ITEMS | ITEM= 74, 943 words | | |-------------------------| | | | TEXT STRINGS | STRNG= 110, 865 words | | |-------------------------| | | | CONTROL STRINGS | CNTRL= 115, 911 words | | |-------------------------| | | | WORK SPACE | WORK AREA= 30, 100 words | | | | ^ ^ |-------------------------| | | | | TABLE INDEX and TABLE LENGTH entities--------------------+ | | TABLE REGISTER entities-------------------------+ Figure C-9. Table Register Entities of a Multiple-Segment Program Programs Using CALLs Without the SWAP Option Splitting Transact programs into subprograms also decreases stack requirements. Figure C-10 shows the compiler statistics for the program used for the earlier examples, restructured into a main program and four subprograms. The main program statistics appear on the first page and statistics for the subprograms appear on the subsequent four pages of the listing. Figure C-11 shows the layout of the run-time data stack. Note that the top half of the stack, used by the main program, has the same components as the single-segment program data stack. The PROCESSOR PROC. VAR. area holds processor variables for calling subprograms; the size of this area is version-dependent. The next area is a second Transact PROCESSOR CONTROL BLOCK. The remaining areas are used by entities of the CALLed subprograms. Figure C-12 portrays the entities in the TABLE REGISTER, TABLE INDEX, and TABLE LENGTH components for the main program. main program COMPILING WITH OPTIONS: CODE,DICT,STAT,ERRS *****COMPILE TIME STATISTICS**** STACK= 11208 TABLE= 962 *******RUN TIME STATISTICS****** PCODE= 0 SCODE= 54 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 2, 83 SET= 0, 0 PROC= 0, 0 $$CMD= 11, 65 $CMD= 0, 0 ITEM= 1, 9 STRNG= 10, 67 CNTRL= 2, 5 ------------ 27, 239 ****FINAL TABLE REG. SUMMARY**** WORK AREA= 5, 50 ------------ TABLE REG.= 289 TABLE INDX= 32 TABLE LEN.= 32 *****RUN TIME STACK SUMMARY***** DATA REG.= 200 TABLE REG.= 289 TABLE INDX= 32 TABLE LEN.= 32 ROOT SEG.= 54 ITEM REG.= 25 DATA INDEX= 25 DATA LEN.= 25 ------------ 682 CODE FILE STATUS: REPLACED Figure C-10. Compiler Statistics for Program Using CALLs Without the SWAP Option (1 of 5) subprogram 1 COMPILING WITH OPTIONS: CODE,DICT,STAT,ERRS *****COMPILE TIME STATISTICS**** STACK= 11208 TABLE= 3262 *******RUN TIME STATISTICS****** PCODE= 0 SCODE= 590 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 8, 163 SET= 6, 87 PROC= 0, 0 $$CMD= 11, 65 $CMD= 0, 0 ITEM= 28, 348 STRNG= 33, 413 CNTRL= 25, 159 ------------- 112, 1245 ****FINAL TABLE REG. SUMMARY**** WORK AREA= 5, 50 ------------- TABLE REG.= 1295 TABLE INDX= 117 TABLE LEN.= 117 *****RUN TIME STACK SUMMARY***** DATA REG.= 100 TABLE REG.= 1295 TABLE INDX= 117 TABLE LEN.= 117 ROOT SEG.= 590 ITEM REG.= 20 DATA INDEX= 20 DATA LEN.= 20 ------------ 2279 CODE FILE STATUS: REPLACED Figure C-10. Compiler Statistics for Program Using CALLs Without the SWAP Option (2 of 5) subprogram 2 COMPILING WITH OPTIONS: CODE,DICT,STAT,ERRS *****COMPILE TIME STATISTICS**** STACK= 11208 TABLE= 4125 *******RUN TIME STATISTICS****** PCODE= 0 SCODE= 1101 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 11, 190 SET= 6, 87 PROC= 0, 0 $$CMD= 11, 65 $CMD= 0, 0 ITEM= 19, 240 STRNG= 54, 468 CNTRL= 13, 45 ------------ 115, 1105 ****FINAL TABLE REG. SUMMARY**** WORK AREA= 8, 60 ------------ TABLE REG.= 1165 TABLE INDX= 123 TABLE LEN.= 123 *****RUN TIME STACK SUMMARY***** DATA REG.= 100 TABLE REG.= 1165 TABLE INDX= 123 TABLE LEN.= 123 ROOT SEG.= 1101 ITEM REG.= 20 DATA INDEX= 20 DATA LEN.= 20 ------------ 2672 CODE FILE STATUS: REPLACED Figure C-10. Compiler Statistics for Program Using CALLs Without the SWAP Option (3 of 5) subprogram 3 COMPILING WITH OPTIONS: CODE,DICT,STAT,ERRS *****COMPILE TIME STATISTICS**** STACK= 13640 TABLE= 5622 *******RUN TIME STATISTICS****** PCODE= 0 SCODE= 1456 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 19, 310 SET= 10, 146 PROC= 0, 0 $$CMD= 11, 65 $CMD= 0, 0 ITEM= 20, 249 STRNG= 66, 793 CNTRL= 32, 120 ------------ 159, 1693 ****FINAL TABLE REG. SUMMARY**** WORK AREA= 8, 60 ------------ TABLE REG.= 1753 TABLE INDX= 167 TABLE LEN.= 167 *****RUN TIME STACK SUMMARY***** DATA REG.= 100 TABLE REG.= 1753 TABLE INDX= 167 TABLE LEN.= 167 ROOT SEG.= 1456 ITEM REG.= 20 DATA INDEX= 20 DATA LEN.= 20 ------------ 3703 CODE FILE STATUS: REPLACED Figure C-10. Compiler Statistics for Program Using CALLs Without the SWAP Option (4 of 5) subprogram 4 COMPILING WITH OPTIONS: CODE,DICT,STAT,ERRS *****COMPILE TIME STATISTICS**** STACK= 13640 TABLE= 5178 *******RUN TIME STATISTICS****** PCODE= 0 SCODE= 652 ***PARTIAL TABLE REG. SUMMARY*** BASE= 1, 10 FILE= 2, 82 SET= 10, 144 PROC= 0, 0 $$CMD= 11, 65 $CMD= 0, 0 ITEM= 57, 735 STRNG= 103, 796 CNTRL= 68, 703 ------------ 252, 2535 ****FINAL TABLE REG. SUMMARY**** WORK AREA= 40, 200 ------------ TABLE REG.= 2735 TABLE INDX= 292 TABLE LEN.= 292 *****RUN TIME STACK SUMMARY***** DATA REG.= 200 TABLE REG.= 2735 TABLE INDX= 292 TABLE LEN.= 292 ROOT SEG.= 652 ITEM REG.= 25 DATA INDEX= 25 DATA LEN.= 25 ------------ 4246 CODE FILE STATUS: REPLACED Figure C-10. Compiler Statistics for Program Using CALLs Without the SWAP Option (5 of 5) |--------------------------| | PCBX | |--------------------------| | VPLUS INFO | |--------------------------| | Transact OUTER BLOCK | 66 words |--------------------------| | Transact PROC. CNTL. BLK.| 816 words |--------------------------| | DATA REGISTER |DATA REG.= 200 words |--------------------------| | TABLE REGISTER |TABLE REG.= 289 words--\ |--------------------------| \ | TABLE INDEX |TABLE INDX= 32 words ---\---see Figure C-12 |--------------------------| / | TABLE LENGTH |TABLE LEN.= 32 words --/ |--------------------------| | CODE REGISTER |ROOT SEG.= 54 words |--------------------------| | ITEM REGISTER |ITEM REG.= 25 words |--------------------------| | DATA INDEX |DATA INDEX= 25 words |--------------------------| | DATA LENGTH |DATA LEN.= 25 words |--------------------------| | PROCESSOR PROC. VAR. | 194 words |--------------------------| | Transact PROC. CNTL. BLK.| 816 words |--------------------------| | TABLE REGISTER |TABLE REG.= 2735 words |--------------------------| | TABLE INDEX |TABLE INDX= 292 words |--------------------------| | TABLE LENGTH |TABLE LEN.= 292 words |--------------------------| | CODE REGISTER |ROOT SEG.= 652 words |--------------------------| | ITEM REGISTER |ITEM REG.= 25 words |--------------------------| | DATA INDEX |DATA INDEX= 25 words |--------------------------| | DATA LENGTH |DATA LEN.= 25 words |--------------------------| | | ---------- Approx. Total Data Stack = 6620 words Figure C-11. Data Stack of Program Using CALLs Without the SWAP Option |-------------------------| | | | BASES | BASE= 1, 10 words | | |-------------------------| | VPLUS COMAREA; VPLUS, | FILE= 2 83 words | KSAM, MPE, AND DATA | | SET FILE INFO | SET= 0, 0 words |-------------------------| | PROCEDURES | PROC= 0, 0 words |-------------------------| | COMMANDS | $$CMD= 11, 65 words |-------------------------| | SUBCOMMANDS | $CMD= 0, 0 words |-------------------------| | | | ITEMS | ITEM= 1, 9 words | | |-------------------------| | | | TEXT STRINGS | STRNG= 10, 67 words | | |-------------------------| | | | CONTROL STRINGS | CNTRL= 2, 5 words | | |-------------------------| | | | WORK SPACE | WORK AREA= 5, 50 words | | | | ^ ^ |-------------------------| | | | | TABLE INDEX and TABLE LENGTH entities--------------------+ | | TABLE REGISTER entities-------------------------+ Figure C-12. Table Register Entities of Main Program Using CALLs Without the SWAP Option Programs Using CALLs with the SWAP Option If your main program is large, the SWAP option can reduce the amount of data stack space required. This option causes some of the main program's stack entities to be written out to a temporary file when a subprogram is called. The trade-off in this instance is the overhead required to create this file and restore its contents when control returns to the main program. The compiler statistics provided for this program structure are the same as those provided when a program uses CALLs without the SWAP option. Refer back to Figure C-10 for compiler statistics produced when the earlier example was recoded to use the SWAP option with its CALLs. When the main program is in control, the data stack looks like the top portion of the layout illustrated in Figure C-11 . Components PCBX through PROCESSOR PROC. VAR. are present. Figure C-13 illustrates how the data stack looks after subprogram 4 is called: * Only a subset of the main program's TABLE REGISTER, TABLE INDEX, and TABLE LENGTH components are on the stack. The remainder of the entities have been placed in a temporary MPE file. * The following components of the main program have also been placed in the temporary file: CODE REGISTER, ITEM INDEX, and DATA LENGTH. * Two areas of the data stack are used for processor variables: PROCESSOR PROC. VAR. and SWAP PROC. VARIABLES. As in the case of CALLs without the SWAP option, the number of words in these areas is version dependent. The entities in the main program's table register subsets are identified in Figure C-14 . Note that the values for BASE=, FILE=, and SET= entities are represented in the compiler statistics for the main program in the PARTIAL TABLE REG. SUMMARY (refer to the first page of Figure C-10 ). Figure C-15 illustrates the table components for the largest subprogram--subprogram 4. |--------------------------| | PCBX | |--------------------------| | VPLUS INFO | |--------------------------| | Transact OUTER BLOCK | 66 words |--------------------------| | Transact PROCESSOR | | CONTROL BLOCK | 816 words |--------------------------| | DATA REGISTER |DATA REG.= 200 words |--------------------------| | SUBSET OF TABLE REGISTER | 93 words--\ |--------------------------| \ | SUBSET OF TABLE INDEX | 3 words ---\--see Figure C-14 |--------------------------| / | SUBSET OF TABLE LENGTH | 3 words --/ |--------------------------| | PROCESSOR PROC. VAR. | 194 words |--------------------------| | SWAP PROC. VARIABLES | 67 words |--------------------------| | Transact PROCESSOR | 816 words | CONTROL BLOCK | |--------------------------| | TABLE REGISTER |TABLE REG.= 2735 words--\ |--------------------------| \ | TABLE INDEX |TABLE INDX= 292 words ---\--see Figure C-15 |--------------------------| / | TABLE LENGTH |TABLE LEN.= 292 words --/ |--------------------------| | CODE REGISTER |ROOT SEG.= 652 words |--------------------------| | ITEM REGISTER |ITEM REG.= 25 words |--------------------------| | DATA INDEX |DATA INDEX= 25 words |--------------------------| | DATA LENGTH |DATA LEN.= 25 words |--------------------------| | | ---------- Approx. Total Data Stack = 6304 words Figure C-13. Data Stack of Program Using CALLs With the SWAP Option (CALLed Program is on the Stack) |-------------------------| | | | BASES |BASE= 1, 10 words | | |-------------------------| | VPLUS COMAREA; VPLUS, |FILE= 2, 83 words | KSAM, MPE, & DATA | | SET FILE INFO |SET = 0, 0 words |-------------------------| ^ ^ | | | | TABLE INDEX and TABLE LENGTH entities---------------+ | | | TABLE REGISTER entities---------------------+ Figure C-14. Table Register Subsets for Main Program After CALLing Subprogram |-------------------------| | | | BASES | BASE= 1, 10 words | | |-------------------------| | VPLUS COMAREA; VPLUS, | FILE= 2 82 words | KSAM, MPE, AND DATA | | SET FILE INFO | SET= 10, 144 words |-------------------------| | PROCEDURES | PROC= 0, 0 words |-------------------------| | COMMANDS | $$CMD= 11, 65 words |-------------------------| | SUBCOMMANDS | $CMD= 0, 0 words |-------------------------| | | | ITEMS | ITEM= 57, 735 words | | |-------------------------| | | | TEXT STRINGS | STRNG= 103, 796 words | | |-------------------------| | | | CONTROL STRINGS | CNTRL= 68, 703 words | | |-------------------------| | | | WORK SPACE | WORK AREA= 40, 200 words | | | | ^ ^ |-------------------------| | | | | TABLE INDEX and TABLE LENGTH entities--------------------+ | | TABLE REGISTER entities-------------------------+ Figure C-15. Table Register Entities of Subprogram 4 Stack Usage Comparison The following table summarizes the data stack requirements of the four program examples just examined. The values shown do not include the stack space required for the following components: PCBX, VPLUS, and subsystems such as SORT. Table C-1. Example of Data Stack Requirements --------------------------------------------------------------------------- | | | | | | | Application Structure | Approximate Data | | | Stack | | | | | | | --------------------------------------------------------------------------- | | | | Single-Segment Program | 10957 words | | | | | Multiple-Segment Program | 7197 words | | | | | Main Program CALLing Sub-Programs Without SWAP | 6620 words | | Option | | | | | | Main Program CALLing Sub-Programs With SWAP | 6304 words | | Option | | | | | --------------------------------------------------------------------------- The main program in the final case is very small, so the savings in stack space are not as significant as they could be.


MPE/iX 5.0 Documentation