Guardian Procedure Calls Reference Manual
The SEGMENT_GET_MIN_ALIGN_ Procedure (page 1282) reports the minimum alignment for
a specified segment size. This minimum alignment is recommended for all segments, and is
enforced for segments in 64-bit address space. For historical compatibility, the enforced
minimum alignment in 32-bit address space is a single page (16 KB on all G-, H- and J-series
RVUs). For all segments, the SEGMENT_GET_PREF_ALIGN_ Procedure (page 1284) procedure
reports the preferred (optimum) alignment for a specified segment size. The preferred alignment
can vary with the platform and release version, so for maximum portability use the value
returned by the function rather than a hard-coded value.
When the base-address is neither specified explicitly nor inferred from a shared segment,
segments are allocated in the first adequate available address range, starting from high
addresses in 32-bit address space or low addresses in 64-bit address space. Because of the
alignment optimization, successive flat segment allocations are not necessarily contiguous and
not necessarily in consecutive order; smaller segments may be allocated in address ranges
left vacant between larger segments.
A segment of size slightly larger than a power of two may be assigned an address aligned
on a larger power of two, so multiple such segments may be separated by a large amount of
unallocated space. The result can be significant fragmentation of the address space. Here are
suggested ways to avoid such fragmentation:
◦ Avoid segment sizes that are just slightly more than a power of two.
◦ Allocate fewer and larger segments.
◦ When many areas of awkward or unpredictable sizes are needed, perform your own
sub-allocation within larger segments, using either the available heap/pool management
procedures or your own specialized algorithms tailored to the application. The POOL32_...
and POOL64_... procedures provide efficient heap management facilities; see POOL32_...
and POOL64_... Procedures (page 953). They support a pool (heap) in either a single
large segment that can be resized, or in multiple segments that can be dynamically added
to or removed from the pool.
It is possible to reduce fragmentation by specifying the base-address to force segment
allocations at sub-optimal alignments. Users pursuing this approach are strongly encouraged
to observe the minimum alignment recommendations, because large badly aligned segments
can significantly reduce performance in terms of both time and memory space for the memory
management activities. The minimum alignment recommendations are listed in the description
of the SEGMENT_GET_MIN_ALIGN_ Procedure (page 1282).
• Flat segments and increased performance
Although the SEGMENT_USE_ Procedure (page 1298) and MOVEX Procedure (page 838) can
be used with flat segments, you can improve performance by eliminating SEGMENT_USE_
calls and replacing MOVEX calls with direct access. Programs can determine the type of
segment allocated and take advantage of the flat segment features whenever a flat segment
is allocated.
• Selectable segments and performance
If you have more than one selectable segment, you might face performance degradation,
because time is wasted when switching between the selectable segments. This is because only
one selectable segment is visible at a time. Instead, use flat segments, which are always visible.
• Determining whether a flat segment is allocated
Use these techniques to determine whether a segment obtained is a flat segment:
◦ Check the value returned in the base-address parameter. If the segment is a selectable
segment, the base address is always %2000000D (%H00080000); otherwise, the
1270 Guardian Procedure Calls (S)