THREADSTACK

Derivation: THREAD level STACK storage

THREADSTACK controls the allocation of the thread's stack storage for both the upward and downward-growing stacks, except the initial thread in a multithreaded application.

If the thread attribute object does not provide an explicit stack size, then the allocation values can be inherited from the STACK option or specified explicitly on the THREADSTACK option.

Non-CICS® default
THREADSTACK=((OFF,4K,4K,ANYWHERE,KEEP,128K,128K),OVR)
CICS default
THREADSTACK is ignored under CICS.

1  THREADSTACK = ( (
1! OFF
1 ON
2  ,
2 usinit_size
2  ,
2 usincr_size
2  ,
1! ANYWHERE
1 ANY
1 BELOW
3  ,
1! KEEP
1 FREE
4  ,
4 dsinit_size
4  ,
4 dsincr_size
4  ) ,
1 NONOVR
1! OVR
5  )
OFF
Indicates that the allocation suboptions of the STACK runtime option are used for thread stack allocation. Any other suboption specified with THREADSTACK is ignored. OFF is the default.
ON
Controls the stack allocation for each thread, except the initial thread, in a multithread environment.
usinit_size
Determines the size of the initial upward-growing stack segment. The storage is contiguous. You specify the usinit_size value as n, nK, or nM bytes of storage. The actual amount of allocated storage is rounded up to the nearest multiple of 8 bytes.

usinit_size can be preceded by a minus sign. In environments other than, if you specify a negative number, Language Environment® uses all available storage minus the amount specified for the initial stack segment.

A size of "0" or "-0" requests half of the largest block of contiguous storage in the region below the 16-MB line.

usincr_size
Determines the minimum size of any subsequent increment to the upward-growing stack area. You can specify this value as n, nK, or nM bytes of storage. The actual amount of allocated storage is the larger of two values— usincr_size or the requested size—rounded up to the nearest multiple of 8 bytes

If you specify usincr_size as 0, only the amount of the storage needed at the time of the request, rounded up to the nearest multiple of 8 bytes, is obtained.

The requested size is the amount of storage a routine needs for a stack frame. For example, if the requested size is 9000 bytes, usincr_size is specified as 8K, and the initial stack segment is full, Language Environment gets a 9000-byte stack increment from the operating system to satisfy the request. If the requested size is smaller than 8 K, Language Environment gets an 8 K stack increment from the operating system.

ANYWHERE | ANY | BELOW
Specifies the storage location. For downward growing stack, this option is ignored and the storage is always placed above 16 MB.
BELOW
Specifies that the stack storage must be allocated below the 16 MB line in storage that is accessible to 24-bit addressing.
ANYWHERE|ANY
Specifies that stack storage can be allocated anywhere in storage. If there is no storage available above the line, Language Environment acquires storage below the 16-MB line.
KEEP | FREE
Determines the disposition of the storage increments when the last stack frame in the increment segment is freed.
KEEP
Specifies that storage that is allocated to stack increments is not released when the last of the storage in the stack increment is freed. KEEP is the default.
FREE
Specifies that storage that is allocated to stack increments is released when the last of the storage in the stack is freed. The initial stack segment is never released until the enclave terminates.
dsinit_size
Determines the size of the initial downward growing stack segment. The storage is contiguous. You specify the init_size value as n, nK, or nM bytes of storage. The actual amount of allocated storage is rounded up to the nearest multiple of 16 bytes.
dsincr_size
Determines the minimum size of any subsequent increment to the downward growing stack area. You can specify this value as n, nK, or nM bytes of storage. The actual amount of allocated storage is the larger of two values-- incr_size or the requested size--rounded up to the nearest multiple of 16 bytes.
OVR
Specifies that the option can be overridden. OVR is the default.
NONOVR
Specifies that the option cannot be overridden.

Usage notes

  • The dsinit_size and dsincr_size values are the amounts of storage that can be used for downward growing stack frames (plus the stack header, approximately 20 bytes). The actual size of the storage getmained will be 4 K (8 K if a 4 K page alignment cannot be guaranteed) larger to accommodate the guard area.
  • The downward growing stack is only initialized in an XPLINK supported environment, and only when an XPLINK application is active in the enclave. Otherwise, the suboptions for the downward growing stack are ignored.
  • The THREADSTACK option replaces the NONIPTSTACK and NONONIPTSTACK options.
  • All storage allocated to THREADSTACK segments are freed when the thread terminates.
  • The initial stack segment of the thread is never released until the thread terminates, regardless of the KEEP/FREE state.
  • You can specify suboptions with THREADSTACK(OFF,...), but they are ignored. If you override the THREADSTACK(OFF,...) suboption with THREADSTACK(ON) and you omit suboptions, then the suboptions you specified with THREADSTACK(OFF,...) remain in effect. If you respecify THREADSTACK(OFF,...) with different suboptions, they override the defaults.
  • In the multithreaded environment, you can explicitly specify the stack size in the thread attribute object; it will be used instead of the value specified with THREADSTACK or STACK.
PL/I MTF considerations
THREADSTACK(ON,4K,4K,BELOW,KEEP,,) provides PL/I compatibility for stack storage allocation and management for each subtask in the application.
PL/I considerations
For multitasking or multithreaded environments, the stack size for a subtask or non-Initial Process Thread (non-IPT) is taken from the THREADSTACK option unless THREADSTACK(OFF) is specified. THREADSTACK(OFF) specifies that the values in the STACK option be used.

For more information

  • For more information about the STACK runtime option, see STACK.
  • For more information about the ALL31 runtime option, see ALL31.