Menu

SecondaryStack

Simon Wright

The secondary stack is what GNAT uses to manage functions which return objects of an indefinite type: for example,

function F return String;

Desktop GNAT manages the secondary stack in the heap, so that it can be of unbounded size. This implementation, however, manages it by carving out a proportion of each task’s stack; currently this is 10%, but this can be altered globally in System.Parameters (s-parame.adb) in function Secondary_Stack_Size:

function Secondary_Stack_Size (Stack_Size : Size_Type) return Size_Type
  is ((Stack_Size * 10) / 100);

If you have a function returning a large indefinite type (a long String, say, or an indefinite array of large objects), you’ll need to allocate a larger stack for the using task:

task type T
with
  Storage_Size => 10_000
is
end T;

Note:

  • Storage_Error will be raised if you try to use more secondary stack than is available.
  • The main program's secondary stack has size 256 (see s-secsta.adb if you need to change this).

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.