From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Storage_Size in a Simple Program Date: Fri, 26 Oct 2018 00:32:30 +0300 Organization: Tidorum Ltd Message-ID: References: <1nx0yp3.x6ss3k18nq71lN%csampson@inetworld.net> <1nx5k9a.1n8zqjs1xf0pe6N%csampson@inetworld.net> <50b40e43-623a-4015-95b3-91c5d4736e53@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net jG0zSn11O3mqPEkT/BwAIgI8OmdXu36dn0vkn4IsDa4p/WAB+H Cancel-Lock: sha1:sicHeWKhB+Yam8kbnaqR4iJZBXQ= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: reader02.eternal-september.org comp.lang.ada:54709 Date: 2018-10-26T00:32:30+03:00 List-Id: 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 . @ .