NonStop S-Series Server Description Manual (G06.24+)

TNS Execution Modes
HP NonStop S-Series Server Description Manual520331-003
6-30
Basic Characteristics of Procedures
Basic Characteristics of Procedures
Procedures are the fundamental building blocks of programs. They are compiled in
contiguous locations in a program file, and when the program is dispatched into
execution as a process, the procedures appear in a code segment of virtual memory
as shown in Figure 6-18.
A procedure is a functional block of instructions that, when called into execution,
performs a specific operation. It consists of a block of TNS instruction codes and
program constants. A procedure can call another procedure within its own segment, or
it can make an external call to a procedure in another segment of the same space or in
any other available code space (UC, UL, SC, or SL).
When one procedure calls another, the caller’s environment is automatically saved
before the other procedure begins, and the caller’s environment is restored when the
called procedure finishes. Parameters (or arguments) can be passed to the called
procedure for evaluation, either as actual operands or as addresses of operands.
Also, a procedure can return a value (such as the result of a computation) to its caller.
The address of the first instruction to be executed in a procedure is called the entry
point. (A procedure can have multiple entry points.) All entry points for all procedures
in a segment are located in a table, accessible by the hardware, called the procedure
entry point (PEP) table. The PEP table itself is located at the beginning of each code
segment.
The external entry point (XEP) table, also shown in the illustration, exists in each
segment and is used when calling procedures in other code segments. (It is discussed
in the topic Calling External Procedures on page 6-64.) This table ends on a page
boundary, with entries consecutively assigned backward toward the end of code, using
the first available space that fits (either on the same page as the end of code or on a
separate page).
A procedure itself can contain one or more subprocedures. A subprocedure is similar
to a procedure but can be called only by the procedure that contains it or by another
subprocedure contained within the procedure. However, it has no entry in the PEP
table and is implemented by a simple branch and return instruction pair (BSUB and
RSUB). It executes only in the mode of its caller (nonprivileged or privileged).
Procedures are assigned a callability attribute. The attribute specifies whether or not
the caller must already be executing in privileged mode and whether or not the called
procedure executes in privileged mode. Attributes are considered next.