comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Maximum Number Of Tasks?
Date: Tue, 12 Nov 2013 21:02:46 +0100
Date: 2013-11-12T21:02:46+01:00	[thread overview]
Message-ID: <87zjp9ie1l.fsf@ludovic-brenta.org> (raw)
In-Reply-To: 64c53708-0397-4b21-abcc-b33aa56b48f4@googlegroups.com

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.


  reply	other threads:[~2013-11-12 20:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12  9:53 Maximum Number Of Tasks? FritzVonBraun
2013-11-12 10:59 ` Jacob Sparre Andersen
2013-11-12 12:52 ` Georg Bauhaus
2013-12-06  3:26   ` Brad Moore
2013-11-12 13:21 ` mockturtle
2013-11-12 20:02   ` Ludovic Brenta [this message]
2013-11-12 20:04     ` Ludovic Brenta
2013-11-12 15:54 ` Jeffrey Carter
2013-11-12 16:17   ` Dmitry A. Kazakov
2013-11-14 13:00 ` Marius Amado-Alves
replies disabled

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