MPE SEGMENTER Reference Manual HP 3000 Computer Systems ABCDE HP Part No. 30000-90011 Printed in U.S.A.
The information contained in this document is subject to change without notice. HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance or use of this material.
PRINTING HISTORY New editions are complete revisions of the manual. Update packages, which are issued between editions, contain additional and replacement pages to be merged into the manual by the customer. The dates on the title page change only when a new edition or a new update is published. No information is incorporated into a reprinting unless it appears as a prior update; the edition does not change when an update is incorporated.
iv DRAFT 2/11/100 10:13
There are many more manuals applicable to the HP 3000. A complete list may be found in every issue of the MPE V Communicator. Please contact your System Manager. PREFACE This manual describes how you can use the MPE Segmenter to manage shared code stored in library les and to control the segmentation of program code.
CONVENTIONS USED IN THIS MANUAL NOTATION COMMAND KEYWORDS parameter parameter [] DESCRIPTION Commands are shown in CAPITAL LETTERS. The names must contain no blanks and be delimited by a non-alphabetic character (usually a blank). Literal keywords, which are entered optionally but exactly as speci ed, appear in CAPITAL LETTERS. Required parameters, for which you must substitute a value, appear in bold italics . Optional parameters, for which you may substitute a value, appear in standard italics .
... An ellipsis indicates that a previous bracketed element may be repeated, or that elements have been omitted. In examples of interactive dialog, user input is underlined. user input Example: NEW NAME? ALPHA1 superscriptc Control characters are indicated by a superscriptc . 4RETURN5 Example: Yc . (Press Y and the CNTL key simultaneously.) 4RETURN5 indicates the carriage return key.
1 Introduction To The Segmenter Situation Checklist You need to study this manual in detail under these circumstances: When you start developing programs if your facility requires large, complex applications programs. If you've inherited programs from another programmer and don't understand what the Segmenter commands are doing. If you can't prepare a program because your code segment is too large. When you have exceeded the limit of 255 code segments in your program le.
Virtual Memory And Segmentation Because memory capacity is limited, all computer systems need some method of separating code and data into units and moving these units in and out of main memory as they are needed. HP has developed a solution based on \virtual memory" and \segmentation.
Segmentation Segmentation is the separation of code into various-sized pieces, or \segments," according to logical, rather than physical, considerations. It is the most e cient means of implementing the HP 3000's virtual memory design. The HP 3000 can follow system defaults to segment your program. You can also handle the segmentation yourself, using embedded control statements to the compiler or commands to the Segmenter, which is a subsystem of the MPE operating system.
Sharable code environment Because the HP 3000 maintains code and data in strictly separate environments, and because code is non-modi able during execution, HP 3000 code is sharable among many users. HP 3000 code is also re-entrant: when a program is interrupted during execution of a code segment and another user's execution needs the same segment, that segment can be used, is completely protected against modi cation, and will be returned intact to the previous user's execution.
The Segmenter The Segmenter is a subsystem of the MPE operating system. It performs all intermediate functions between source code compilation and program execution. One of its primary responsibilities is to gather and link into pieces, or segments, most of the resources needed to form an executable program le.
Figure FIGURE11 here. Figure 1-1. Program Development Overview User Subprogram Library (USL): preliminary plans. Program le: nal plans. The program development process is analogous to the architectural process of designing the condominium. The architect takes her ideas and translates them into a preliminary plan. This oorplan may contain one or more rooms per oor, and each room may have one or more doors.
Compilation The rst step, illustrated in Figure 1-2, is to translate the source program units (sometimes called procedures, functions, or subroutines) into blocks of machine instructions called \relocatable binary modules", or RBMs. This is done by the various MPE language compilers, which automatically store the RBMs in a specially-formatted le called the user subprogram library, or USL. Figure FIGURE12 here. Figure 1-2. Compilation An RBM is the smallest unit of object code generated by a compiler.
When the compiler places the RBMs in the USL le, it \associates" them with particular code segments. Actual code segments do not yet exist, but you can think of the RBMs as \belonging" to their associated segments. The RBMs are relocatable, which means that using the Segmenter you can move RBMs around and associate them with di erent code segments. You can also copy RBMs from other USLs, add new RBMs to a USL, or purge RBMs. An analogy will help clarify some of the important characteristics of RBMs.
A major advantage of this library is that once code is compiled into the USL, the programmer can manipulate it and even copy it into another USL without having to perform time-consuming recompilation. Users can also compile several versions of a procedure into a USL, using the Segmenter's indexing capability to select at execution time the version they wish to use. Although USLs are usually created by the compiler, the programmer can create them, using commands within the Segmenter subsystem.
During preparation, the Segmenter uses the associations found in the USL to bind the RBMs into one or more code segments. It is important to realize that no segments actually existed in the USL. By associating RBMs with segments, the compiler was, in e ect, looking forward to segments which would eventually be created. That creation is the sole responsibility of the Segmenter. Code segments..
To construct the data segment, the Segmenter uses the initial stack information compiled into the USL. That information de nes and initializes storage space for data that is considered global (available to all program units directly). This area, usually referred to as the Primary DB, contains information about and pointers into the other parts of the data segment.
Di erent programming languages have di erent rules for the speci c kinds of code that may be placed in an RL; these are discussed in the reference manual for each language. All languages allow you to place either global or non-global procedures in an RL. Global procedures reference the global storage area of a program's data stack, so that the system will have instructions on how to handle the RL code that are appropriate to each particular le in which it is used.
The Segmented Library, or SL, is the third of the three libraries which may be accessed during the program development process. An already-existing system SL contains procedures applicable to all HP 3000 systems, such as the procedure for program termination.
into memory from its place in disc storage. This method makes economical use of system resources, since each SL procedure exists only once in main memory and does not need to be brought in as part of every program le that requires it. As is true of RLs, the various programming languages have di erent rules for what kinds of code may go into an SL. The general requirement, however, is that SLs can only contain non-global procedures.
procedures while your program is running, searches the SL libraries according to the user's log-on group and account, or the group and account where the program resides, as speci ed by the 'LIB ' parameter. See the discussion of the LOADPROC intrinsic in the MPE V Intrinsics Reference Manual (32033-90007) for more information. The search order and the number of libraries searched depend on the the ;LIB parameter speci ed as part of either the :RUN or the :PREPRUN commands.
Although it is often referred to as a single table, the CST is actually divided, logically and physically, into two portions: The CST contains entries for coded segments in segmented libraries (including the system SL, which contains large chunks of the MPE operating system). Some entries or parts of entries in the CST also contain various service procedures for internal interrupts, external interrupts, system intrinsics, and library procedures.
Like the Code Segment Table, the Data Segment Table is a main-memory resident table which is maintained by the MPE operating system. It contains a list of data segments currently in use by the operating system and user programs. Each segment receives a four-word entry recording its length, location, presence or absence in main memory, and other characteristics. The data segment table. The length of the table is determined at system generation time.
2 Using The Segmenter Accessing And Exiting The Segmenter In an interactive session, you access the Segmenter implicitly whenever you use the MPE :PREPARE command, or when you use any of the combination commands such as: :PREPRUN object code lename (prepares and executes in one step) :BASICPREP source code :BASICGO source code lename (compiles and prepares in one step) lename (compiles, prepares and executes in one step) If you want to directly manipulate code yourself, you need to access the Segmenter
to -EXIT, make the le equation, and re-invoke the Segmenter using the le reference. When you enter the :SEGMENTER command, the Segmenter responds with the following message and displays a dash prompt character: HP32050A.03.00 SEGMENTER/3000 (c) HEWLETT PACKARD CO. 1986 - You can now enter Segmenter commands.
Manipulating RBMs Although the compilers and the Segmenter provide the required RBM management in most circumstances, you may want to take explicit control of RBMs for one of the following reasons: To use common code from another USL le. To change the number of code segments associated with a program. To create more e cient programs by relocating or purging RBMs or activating/deactivating a version of an RBM. RBMs are units of source code which have been compiled into a User Subprogram Library (USL).
listed above, the only points of overlap are the assignment of RBMs to speci c segments and the speci cation of segment size. Further, as the compiler options listed above indicate, the compiler's management of RBMs is limited to control of segmentation. The Segmenter gives you this capability and several others as well.
INDEX=n INDEX=0 (Default) ALL COMMANDS nth version, active or most recent active version EXCEPT CEASE AND inactive USE CEASE nth version, active or most recent active version inactive USE nth version, active or most recent inactive version inactive Study the -CEASE and -USE commands in Section IV of this manual for more information about why the index works di erently with them than with the other Segmenter commands.
ABC **4** FILE DIR. DIR. DIR. SIZE USED GARB. AVAIL. 16 P 144000 70 0 14310 I C N R INFO USED INFO GARB. INFO AVAIL. 130 0 127050 Each RBM retains its particular index until an RBM is deleted from or added to the USL. Then the index is reset. With a deletion, all older versions (those with higher index numbers than the deleted RBM) receive a new index: their old value minus one. With an addition, the newest RBM receives the index 1 and all older versions receive their old value plus one.
**1 - to be moved** ABC **2** ABC **2** XYZ **1** XYZ **1** XYZ **2** XYZ **2** SEGASK ABC **1 - moved** SEGASK ABC **4** ABC **4** ABC **5** ABC **5** As you will see in the following discussion, the index signi cantly increases your power and exibility in manipulating RBMs. However, to use it successfully you will need to keep your own records, either on-line or o -line, of what is in the various versions.
Purge RBMs. Activate/deactivate RBMs. Add new RBMs to a USL. Transfer RBMs from other USLs to the one you are currently using. Note: the nal item is discussed under Managing the USL. The -NEWSEG command allows you to change the segment name associated with an RBM, thus assigning the RBM to a di erent code segment the next time it is prepared onto a program le. With the command Controlling Segment Association.. -NEWSEG SUB, TIMESTWO you are associating the RBM TIMESTWO with the segment named SUB.
without specifying either UNIT or SEGMENT, the Segmenter defaults to UNIT, thus shortening the amount of information you must type when you are managing RBMs as well as protecting you from accidentally purging more RBMs (or more versions of an RBM) than you intend to. ***: undefined*** illustrates the use of the -PURGERBM command. Segmenter commands allow you to activate or deactivate RBMs according to various \entry points.
-USL $OLDPASS -LISTUSL USL FILE $OLDPASS SEG' TIMESTWO MAIN' FILE DIR. DIR. DIR. SIZE USED GARB. AVAIL. 16 P A C N R 32 OB A C N 144000 70 0 14310 INFO USED INFO GARB. INFO AVAIL. 130 0 127050 -NEWSEG SUB,TIMESTWO -PURGERBM MAIN' **Add segment SUB. Put RBM TIMESTWO into SUB. Delete RBM MAIN'** -LISTUSL USL FILE $OLDPASS SUB TIMESTWO SEG' **Null segment** FILE DIR. DIR. DIR. SIZE USED GARB. AVAIL. 16 P 144000 76 31 14302 A C N R INFO USED INFO GARB. INFO. AVAIL.
SUB TIMESTWO FILE DIR. DIR. DIR. 16 P SIZE USED GARB. AVAIL A C 144000 76 73 14302 N R INFO USED INFO GARB. INFO AVAIL. 130 130 127050 Figure 2-1. Using the Segmenter -PURGERBM Command :FORTRAN SEG8 PAGE 0001 HP32102B.00.
:SEGMENTER HP32050A.03.00 SEGMENTER/3000 HEWLETT-PACKARD CO. 1986 -USL $OLDPASS -LISTUSL USL FILE $OLDPASS SEG' TIMESTWO MAIN' FILE DIR. DIR. DIR. SIZE USED GARB. AVAIL. 16 32 144000 70 73 14302 P A C OB A C N R N INFO USED INFO. GARB. INFO. AVAIL. 130 130 127050 Figure 2-2.
When the Segmenter prepares a program le from the USL, all RBMs having at least one active entry point are extracted from the USL for segmentation in the program le. Those associated with identical segment names are placed in the same segment. To permit the creation of a program le that can be executed properly, only one outer-block or main-program RBM can have active entry points, along with the RBMs for the subprograms or procedures.
we instruct the compiler to compile the new subroutine SUB72 into the previously-created USL MASTRUSL. :SEGMENTER HP32050A.03.00 SEGMENTER/3000 (C) HEWLETT-PACKARD CO. 1986 -USL $OLDPASS -LISTUSL USL FILE $OLDPASS.PUB.SPL SEG' **INDEX** ABC 1 P A C N R ABC 1 P I C N R ABC 1 P I C N R ABC 1 P I C N R **1, 0 Most recent active** **2** **3** **4** FILE DIR. DIR. DIR. SIZE USED GARB. AVAIL. 144000( 620. 0) 307( 1.107) 0( 0. 0) 14071( 60. 71) INFO USED INFO GARB. INFO AVAIL.
**INDEX** ABC 1 P I C N R ABC 1 P A C N R ABC 1 P I C N R ABC 1 P I C N R **1** **2, 0 Most recent active** **3** **4** FILE DIR. DIR. DIR. SIZE USED GARB. AVAIL. 144000( 307( 0( 14071( 620. 0) 1.107) 0. 0) 60. 71) INFO USED INFO GARB. INFO AVAIL. 4( 0( 127374( 0. 4) 0. 0) 535.174) Figure 2-3.
Managing User Subprogram Library Files (USLs) A USL is one of the three procedure libraries used in the program development process. It is the le used for compiler output. Most frequently, you will use the USL as input for the Segmenter to use in preparing a program le. However, you may also use it for the following purposes: To share code from another USL or program. To solve code management problems which may occur if you exceed the size limitation established for a USL.
output is written on the le designated in the list le parameter of the MPE :SEGMENTER command, or on $STDLIST if the list le parameter is omitted. In ***: undefined*** , the Segmenter prints information about all segments in the USL, since we didn't specify a particular segment name. Signi cant entries are indicated with item numbers (**number**), which are explained following the listing. All numbers appearing in the listing are octal values.