Compatibility Mode Stack Allocation (new) [ Introduction to MPE XL for MPE V Programmers Migration Guide ] MPE/iX 5.0 Documentation
Introduction to MPE XL for MPE V Programmers Migration Guide
Compatibility Mode Stack Allocation
(new)
In CM, MPE XL emulates the MPE V/E stack, but the operation is somewhat
different. Because of HP-PA, MPE XL has implemented a different stack
allocation scheme in CM than currently exists with the MPE V/E stack.
The difference is primarily how MPE XL implements the CM Z-register.
MPE V/E Stack Allocation
In MPE V/E, it is important to keep the user's stack area as small as
possible to allow for more efficient memory management. This is
accomplished through the use (by both the system and the user) of the
Z-register (or Z) and the MAXDATA parameter found in the CREATE and
CREATEPROCESS intrinsics, and in the RUN command.
The Z-register (or Z) is initialized at process creation time to a value
based upon both the user's DB area size and the value passed in either
the STACK= parameter of the RUN command or, the stacksize parameter of
the CREATE and CREATEPROCESS intrinsics.
During the life of the process, whenever the S-register (or S) exceeds Z,
a stack overflow occurs, and the system increases Z by increments of 512
16-bit words until Z once again exceeds S. These intermediate stack
overflows are handled by the system until both S and Z exceed MAXDATA, at
which time the process is aborted. This mechanism allows the user and
the system to maintain as small a stack segment as possible for the
particular application.
MPE XL CM Stack Allocation
Because of the demand paged virtual memory scheme, MPE XL does not need
to keep the CM stack as small as possible. As a result, there is no
"real" Z-register on MPE XL. Z is a system-managed value used to emulate
the MPE V/E Z-register. To maintain compatibility with MPE V/E, the
initial value of the CM stack's Z is calculated in the same way that Z is
calculated in MPE V/E.
The major difference between MPE XL CM and MPE V/E stack allocation is
that in MPE XL CM, there are no intermediate stack overflows that cause Z
to be incremented by the system. The only time a stack overflow is
detected, is when S exceeds MAXDATA, at which time the process is
aborted. This implementation allows for less overhead in the management
of the CM stack.
However, in order to emulate the relationship between S and Z that exists
on MPE V/E, the algorithm described below is used whenever an application
pushes the Z-register on to the user stack:
1. MPE XL checks to see if S (itself an emulated register) is greater
than Z.
2. If S is greater than Z, MPE XL creates a temporary copy of Z
(Z_PRIME), and adds increments of 512 16-bit words to Z_PRIME
until the value is greater than S (Z_PRIME is never allowed to
exceed MAXDATA).
3. Z_PRIME is pushed on to the user stack (not Z).
From the user's perspective, Z always appears larger than S because it is
Z_PRIME that is pushed on to the user's stack (in fact, Z remains
unchanged).
In MPE XL, when S exceeds Z, the system does not increase Z. Z is
modified only when:
* The ZSIZE intrinsic is called.
* The DLSIZE intrinsic is called.
* The PCBX area of the CM stack is expanded.
In the above three operations, Z is expanded in 512 16-bit word
increments until Z exceeds the current value of the emulated S-register
(although Z is never allowed to exceed MAXDATA).
Impact on Migrated Applications
In MPE V/E, it is common for an application to cause the Z-register to
increase through several intermediate stack overflows. In many cases,
the value of S is then decreased, leaving a large amount of space between
S and Z available for expansion. Thus, when the application checks to
see if there is room on the stack for a data structure, there is usually
plenty of space. However, on MPE XL, the emulated Z-register is not
increased in the same way it is on MPE V/E. The amount of space reported
between S and Z is usually of a much smaller value.
If you want to emulate in CM those increases to the Z-register that occur
in MPE V/E whenever a intermediate stack overflow is detected, you must
call the ZSIZE intrinsic from your application to set the value of Z to
the desired size.
MPE/iX 5.0 Documentation