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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3f60acc31578c72b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!novia!newsfeed.icl.net!proxad.net!news.in2p3.fr!in2p3.fr!kanaga.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: question about tasks, multithreading and multi-cpu machines Date: Fri, 17 Mar 2006 09:22:21 +0100 Organization: CERN - European Laboratory for Particle Physics Message-ID: References: NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1142583741 3947 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060203 Red Hat/1.7.12-1.1.3.4 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:3396 Date: 2006-03-17T09:22:21+01:00 List-Id: Jeffrey R. Carter wrote: >> The difference between "task" and "thread" is that "task" is something >> to do, whereas "thread" is a way to do it. > > The way to design SW in a decent language such as Ada is to create in SW > a model of the problem. If your problem includes multiple tasks to be > completed concurrently, then your SW model of the problem should include > multiple objects which are models of these tasks and which execute > concurrently. Makes sense, but is biased towards single programming paradigm. Consider a simple example of two long vectors that need to be added. In the simplest case you do this: for I in Vector'Range loop V3(I) := V1(I) + V2(I); end loop; and you're done. Now, assume that you want to target dual-CPU machine and you *know* that you could greatly benefit from making things in paraller. Do you see any need to model the above sentence using additional objects? I don't, because in the *application domain* no additional type nor object was created by just computing things in paraller. That's why the "lightweight concurrency", like in Occam, would be more appropriate here. Something like this: declare procedure Add_Range(First, Last : in Index_Range) is begin for I in First .. Last loop V3(I) := V1(I) + V2(I); end loop; end Add_Range; begin Add_Range(Vector'First, Vector'Last / 2); with Add_Range(Vector'Last / 2 + 1, Vector'Last); end; (syntax taken from the top of my head) I see the above as better expressing what is really done. The same example using additional types or objects would not make the code more readable for me. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/