[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


cma_stack_check_limit_np

Determines whether sufficient space exists on the current thread's stack to allocate the requested number of bytes of local storage.

Syntax

cma_stack_check_limit_np(
                          size);
 


Argument Data Type Access

size opaque cma_t_integer read


C Binding

#include 

cma_t_boolean cma_stack_check_limit_np ( cma_t_integer size);

Arguments

size
Number of bytes requested. DECthreads determines whether a stack allocation of the specified size extends beyond the end of the thread's stack.

Description

This routine determines whether sufficient space exists on the current thread's stack to allocate the requested number of bytes of local storage. If the requested size fits (if it does not extend beyond the current thread's stack), cma_c_true is returned. If the requested size extends beyond the end of the stack, cma_c_false is returned.

A DECthreads stack consists of the following three parts:

If the thread does not use the cma_stack_check_limit_np routine, it is possible for a thread to skip over the guard zone of its stack by, for example, allocating a very large array on the stack. If the thread writes to the part of the array that extends beyond its own guard zone before attempting to access the part of the array in its own guard zone, it would corrupt the memory allocated at that location; for example, another thread's stack. This results in unpredictable behavior of the application and is difficult to debug. The cma_stack_check_limit_np routine recognizes that situation and returns cma_c_false.

When cma_stack_check_limit_np is called from the thread that is running on the default process stack, cma_stack_check_limit_np attempts to access each page that would fall within the requested allocation. It returns cma_c_true unless the system is unable to expand the process stack to the needed size.

Returns

Returns a Boolean value that specifies whether the requested size can be allocated without overflowing the current thread's stack. Possible values are:
cma_c_true                      Space can be allocated.

cma_c_false                     Space cannot be allocated.


Exceptions

None



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]