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.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!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:04:12 +0100 Organization: A noiseless patient Spider Message-ID: <87vbzxidz7.fsf@ludovic-brenta.org> References: <64c53708-0397-4b21-abcc-b33aa56b48f4@googlegroups.com> <87zjp9ie1l.fsf@ludovic-brenta.org> 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+Nal/NvwMP+ZSrwOmKeueh" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:uMt+jSQf8fHsyzpV9rrnY0C4+QA= sha1:gK2szeYo50wYM3cmTUSueUsZ9VA= Xref: number.nntp.dca.giganews.com comp.lang.ada:183841 Date: 2013-11-12T21:04:12+01:00 List-Id: Ludovic Brenta writes: > 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 :) Oh and by the way, I will introduce task pools in my demo at FOSDEM 2014 :) -- Ludovic Brenta.