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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bfa293c8cae77433 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-19 10:46:07 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!priapus.visi.com!orange.octanews.net!news.octanews.net!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed.stueberl.de!newsr1.ipcore.viaginterkom.de!btnet-peer1!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: "Martin Dowie" Newsgroups: comp.lang.ada Subject: Re: Tasks problem Date: Fri, 19 Dec 2003 18:45:42 +0000 (UTC) Organization: BT Openworld Message-ID: References: <3fe32ff4$1@news.barak.net.il> NNTP-Posting-Host: host81-129-124-219.in-addr.btopenworld.com X-Trace: sparta.btinternet.com 1071859542 29266 81.129.124.219 (19 Dec 2003 18:45:42 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Fri, 19 Dec 2003 18:45:42 +0000 (UTC) X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MSMail-Priority: Normal X-Priority: 3 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Xref: archiver1.google.com comp.lang.ada:3581 Date: 2003-12-19T18:45:42+00:00 List-Id: "Ratson Janiv" wrote in message news:3fe32ff4$1@news.barak.net.il... > Hi, > I have a task T_Check that checks if a number is a prime one. > I have a task T_Manager that manages the checks. > In T_Manager I have an array of T_Check(1..N). > > Now, lets say I want the T_Manager task to check the numbers 1..100 if they > are prime. > I have only 8 T_Checks tasks (N=6). > How do I manage the tasks allocations ? > I thought about T_Manager getting a notification from T_Check when it > finishes checking, and when T_Manager is notified it shold recall the Check > entry in the T_CHeck task that notified it. > The problem is that I dont know how to know which task (T_Check) amongst the > Nth tasks has notified me. > Is there any solution in ADA? > Maybe my solution is not so good (Hellllllloooooooooo?), what is the > solution U may suggest me ? You could use a rendezvous - how else were you going to return the result to T_Manager? subtype Check_Index is Integer range 1 .. 6; -- or '8'??? task T_Manager is -- No need for a task type if you are only going to have one of them ... accept Notify (Index : Check_Index; N : Integer; Is_Prime : Boolean); ... end T_Manager; task type T_Check (Index : Check_Index) is -- Any other task entries ... entry Check (N : Integer); ... end T_Check; task body T_Manager is Next_Number_To_Check : Integer := 1; begin -- Allocate the checking end T_Manager; task body T_Check is function Check_If_Prime (I : Integer) return Boolean is begin return ...; end Check_If_Prime; Number : Integer; Is_Prime : Boolean; begin ... accept Check (N : Integer) do Number := N; end Check; ... Is_Prime := Check_If_Prime (Number); ... T_Manager.Notify (Index, Number, Is_Prime); ... end T_Check;