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!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx03.iad.POSTED!not-for-mail From: Hubert User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: =?windows-1252?Q?GNAT=A0and_Tasklets?= References: <455d0987-734a-4505-bb39-37bfd1a2cc6b@googlegroups.com> In-Reply-To: <455d0987-734a-4505-bb39-37bfd1a2cc6b@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 141213-1, 12/13/2014), Outbound message X-Antivirus-Status: Clean Message-ID: X-Complaints-To: abuse@newsdemon.com NNTP-Posting-Date: Sun, 14 Dec 2014 00:18:41 UTC Organization: http://www.NewsDemon.com Date: Sat, 13 Dec 2014 16:18:38 -0800 X-Received-Bytes: 2711 X-Received-Body-CRC: 3838744405 Xref: news.eternal-september.org comp.lang.ada:23980 Date: 2014-12-13T16:18:38-08:00 List-Id: > > So my question is : does GNAT create a kernel thread for each local task or is it able to compile local tasks as jobs sent to a pool of tasks created in the runtime ? I asked a similar question about 2 years ago when I was busy implementing a request system on a server (albeit in C++ but I was already ogling at Ada) and I got different answers, depending on the compiler. For me there was an additional requirement though, I had to deal with several 1000s of "Jobs" in parallel, not in hard realtime, but they had to be served as soon as possible. the result of my research was that depending on the OS the Ada program was running on you could get several 100 OS threads or maybe 1-2K on Linux but there is an upper limit because every OS thread that runs a task will have a stack associated with it, so mostly the available memory is the limit, I think. Then when your Jobs use only very limited stack resources, this can be a great waste, especially when thy have different stack requirements so you will ahve to go with the greatest common value which means lots of waste. My solution was to implement my own pre-emptive Job system on top of the OS threads. I allocate as many threads (or Tasks in Ada) as there are processor cores and then assign a number of Jobs to each. The Jobs work internally with a state machine. Whenever they perform a blocking operatin (mostly communicating with other Jobs), they send a message and return control and when the answer arrives, my system calls them again with the next state whee they fetch the answer. Depending on what your requirements are (great number of parallel Jobs), this may very well be your only reliable solution. --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com