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!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx05.iad.POSTED!not-for-mail From: Brad Moore User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Maximum Number Of Tasks? References: <52822462$0$6549$9b4e6d93@newsspool4.arcor-online.net> In-Reply-To: <52822462$0$6549$9b4e6d93@newsspool4.arcor-online.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 68.145.219.148 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1386300390 68.145.219.148 (Fri, 06 Dec 2013 03:26:30 UTC) NNTP-Posting-Date: Fri, 06 Dec 2013 03:26:30 UTC Date: Thu, 05 Dec 2013 20:26:50 -0700 X-Received-Bytes: 3759 X-Received-Body-CRC: 1382403996 X-Original-Bytes: 4001 Xref: number.nntp.dca.giganews.com comp.lang.ada:184091 Date: 2013-12-05T20:26:50-07:00 List-Id: On 12/11/2013 5:52 AM, Georg Bauhaus wrote: > On 12.11.13 10:53, 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. >> >> The reason I'm asking is that I wonder if Ada provides a more comfortable >> solution to the thread pool problem. In C++ for example I create a number of >> threads roughly equal to the number of processor cores and then have a number >> of Jobs that are distributed over the threads and which implement a time >> sharing system by returning control to the thread which then assigns time to >> another Job. > > If you have jobs that do not require intermittent communication among > them, then in particular, I'd be sure to have a look at the Paraffin > library. http://paraffin.sourceforge.net/ > Paraffin has had several flavours of task pools implemented for some time now. You can do as you suggest and have a task pool that has the same number of tasks as there are cores in your system, and distribute work across these tasks. There are three main "flavours" of task pool. 1) No pool at all, just allocate workers on the fly and distribute work across the set of workers 2) A task pool that can be dynamically (or statically) created that contains a bounded (or unbounded) number of workers that can be applied to any number of parallelism opportunities. These task pools allow a worker to migrate to cores, if the OS supports migration (eg. Windows and Linux) 3) A Ravenscar compliant task pool that is more suitable for real time, where the workers must be statically allocated to cores, and cannot migrate. To see a demo of these task pools, you could try running the test_parallel_loops or test_parallel_recursion executables that are included with the source for Paraffin. To see the Ravenscar version of these task pools, you would need to execute the test_ravenscar_parallel_loops and test_ravenscar_parallel_recursion examples. Rather surprisingly, there is not a significant difference between these three task pool models. In general using a task pool will give a slight edge in performance over creating workers on the fly, but the difference is barely noticeable in these examples. Also, intermittent communication between the workers is OK, as long as the communication has the necessary safeguards. For instance you could have several workers performing some lengthy calculation, that briefly writes some value to an IO port. If the IO port was wrapped in a protected object, it may make sense to allow the multiple workers to access this protected object to perform I/O. Brad.