comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Storage_Size in a Simple Program
Date: Fri, 26 Oct 2018 00:32:30 +0300
Date: 2018-10-26T00:32:30+03:00	[thread overview]
Message-ID: <g3er39Fp5avU1@mid.individual.net> (raw)
In-Reply-To: <lymur2j9z6.fsf@pushface.org>

On 18-10-25 18:56 , Simon Wright wrote:
> joakimds@kth.se writes:
>
>>> That said, I would welcome a standard Ada way to specify the stack
>>> size for the environment task. Perhaps Storage_Size could be
>>> specified for the main subprogram, in the same way as the Priority
>>> for the environment task.
>>
>> At
>> "http://www.adaic.org/resources/add_content/standards/05aarm/html/AA-D-1.html"
>> one can read: Likewise, the priority value is associated with the
>> environment task if the pragma appears in the declarative_part of the
>> main subprogram.
>>
>> Therefore, specifying Storage_Size for the main subprogram as can be
>> done with Priority should be technically possible.
>
> On the other hand, I just tried
>
>    with Ada.Text_IO; use Ada.Text_IO;
>    with Interfaces;
>    procedure Main_Stack is
>       Size : Natural := 16;
>       type Arr is array (Natural range <>) of Interfaces.Unsigned_8;
>    begin
>       loop
>          Put_Line ("trying size" & Size'Image);
>          declare
>             A : Arr (1 .. Size) := (others => 0);
>          begin
>             A (A'Last) := 42;
>          end;
>          Size := Size * 2;
>       end loop;
>    end Main_Stack;
>
> on this Mac (High Sierra, 8GB RAM) and it failed at 8 Mb. (ulimit -s
> says 8192k).
>
> If I say ulimit -s 16384, it fails at 16 Mb.
>
> Since the main program's stack limit is determined by the OS, I don't
> see how an Ada aspect/pragma can affect it.

In bare-machine systems, the environment task's stack size is usually 
set in the linker command file, or possibly by a linker option, and 
there is no OS to veto it.

The desire here is to have a standard Ada way of saying (in the Ada 
program itself) what the size _should_ be for the program to work. 
Whether or not the OS agrees to provide that size, or whether the OS has 
to be told to provide it (with ulimit) is a secondary issue.

If some linker/OS combo makes it impossible for a program to define its 
own main-task stack size (within the permitted limit), perhaps the Ada 
program should just check, at start-up, that it _has_ been given enough 
space (that is, at least as much as specified in the program) and if 
not, the program should fail immediately with Storage_Error, say.

At present, there is an Ada way to specify, in the Ada program, how much 
heap memory a certain access type needs, and how much stack a certain 
task needs -- except for the environment task.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .

  reply	other threads:[~2018-10-25 21:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-21 21:35 Storage_Size in a Simple Program Charles H. Sampson
2018-10-22  4:00 ` Simon Wright
2018-10-22  5:46 ` Jacob Sparre Andersen
2018-10-22 11:39   ` joakimds
2018-10-22 12:17     ` Egil H H
2018-10-22 13:51       ` Simon Wright
2018-10-24  9:07 ` Charles H. Sampson
2018-10-24 20:51   ` Niklas Holsti
2018-10-25 13:37     ` joakimds
2018-10-25 15:56       ` Simon Wright
2018-10-25 21:32         ` Niklas Holsti [this message]
2018-10-25 21:39         ` joakimds
2018-10-29 20:58           ` Randy Brukardt
2018-10-30 19:31             ` Niklas Holsti
2018-10-31 20:45               ` Randy Brukardt
2018-10-25 22:23   ` Anh Vo
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox