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: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Maximum Number Of Tasks? Date: Tue, 12 Nov 2013 21:02:46 +0100 Organization: A noiseless patient Spider Message-ID: <87zjp9ie1l.fsf@ludovic-brenta.org> References: <64c53708-0397-4b21-abcc-b33aa56b48f4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="9d523316ade8fbab71301f7762853403"; logging-data="2783"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yziBpBGB0kopB3rWAzVsb" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:QDCC8uTHLWfoNFU7KmJVGiPFU+M= sha1:rI0XvDlm5nJkVLSCqd7E1FxGy3c= X-Original-Bytes: 2563 Xref: number.nntp.dca.giganews.com comp.lang.ada:183840 Date: 2013-11-12T21:02:46+01:00 List-Id: mockturtle writes: > On Tuesday, November 12, 2013 10:53:53 AM UTC+1, FritzVonBraun wrote: >> I was wondering about the maximum number of tasks in Ada but I couldnt >> find any info. The question is, is a task in Ada technically similar to >> a thread in Windows under the hood? Threads are restricted by the stack >> size that each thread has reserved, so in practice the maximum number of >> threads is about 2000. >> > > I remember that I saw at FOSDEM 2013 in the "Ada Developer Room" a > demo that plotted a Mandelbrot set by using a matrix of tasks. A > participant asked then "can you do that with 10_000 tasks?" The size > of the matrix was changed to 100 x 100 and everything worked smoothly; > so, in that case you could create at least 10_000 tasks. The PC was a > laptop running some kind of Linux + GNAT, if I remember correctly. > > Riccardo Yes, you remember correctly; I was the one doing that demo :) That's because the Linux kernel allocates virtual address space to each task but does not allocate any physical memory (RAM or swap) unless and until the task writes to memory (i.e. creates variables on its stack). Even then, Linux only allocates the pages actually written to, not the full 2 MiB (or whatever the default is) per task. After the demo, I re-ran the program at home and saw it allocate 19.8 GiB of virtual address space (I re-checked just now) and thought: gosh am I lucky I've been running 64-bit Linux since 2006 :) -- Ludovic Brenta.