gtpa2m10Application Programming

ISO-C Language Stack

In ISO-C, a stack is used to manage function environments represented by local variables and parameter lists. The stack is allocated from a contiguous virtual address space set aside for the ISO-C stack. The first time a C function is called, an initial storage area (ISA) is set up to handle the C environment and control blocks. It contains a work space (LWS) that can be used by the functions managed by the stack. If the called function calls another function, a new frame is added to the stack. Each frame holds space for information relevant to a given function (such as the automatic variables and a register save area). When the function returns, its frame is removed from the stack and the frame for its caller becomes the current frame.

The largest amount of stack storage an ECB can acquire and the amount of each stack increment are determined by fields in keypoint A. These fields are copied to an ECB page during restart. The amount of the stack increment for an ECB can be adjusted using the ZCTKA ALTER command and in the ECB creation user exit (see UCCECB in TPF System Installation Support Reference). If an ECB exceeds the amount of stack storage initially carved, an overflow routine is called to extend the overall stack size by a stack increment or the current required size. Stack extension is done in multiples of 4KB. If the ECB tries to acquire stack storage greater than the maximum allowed for it, a system error results and the ECB exits.

See ICS0TK DSECT for a detailed layout of the TARGET(TPF) stack frame and the DSECTs IDSDSA and IDSLWS for the ISO-C stack frame layout.