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!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: confusion about message passing between the tasks Date: Sat, 25 Oct 2014 10:54:11 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Sat, 25 Oct 2014 17:54:07 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="206f88a41f45fc94d25d07d064d738e2"; logging-data="25468"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YkVoVkSJsyAgN2QZLVC7YttUmnLWD0d0=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: Cancel-Lock: sha1:mv5FuYoMWW0f0CL37GYKEWM4VyQ= Xref: news.eternal-september.org comp.lang.ada:22732 Date: 2014-10-25T10:54:11-07:00 List-Id: On 10/25/2014 10:25 AM, Dennis Lee Bieber wrote: > On Fri, 24 Oct 2014 09:44:08 -0700 (PDT), compguy45@gmail.com declaimed the > following: > >> I am really kind of lost with tasks and message passing. Would anyone show me an example where 2 tasks would be created by environment task...each task has same body and one entry...so for example one task waits at entry while the other one completes the entry block and on the exit lets waiting task that's its done. > > If they are the "same body and one entry" there is NO WAY to do what > you want. Either both tasks will be waiting on their entry for another to > rendezvous, or both tasks will be blocked waiting to rendezvous on a called > entry. > > First case (pseudo code): > > accept theEntry() -- both blocked waiting for some task to call it > -- note that it can't restrict which task calls > do stuff > end theEntry > other.theEntry() > > Second case: > other.theEntry() -- both blocked waiting for known other task to accept > -- you'll have to initialize each task with the > -- knowledge of the other > accept theEntry() > do stuff > end theEntry That's not entirely true, if the task has a discriminant. For example task type T (First : Boolean); task body T is begin if First then accept E do ... end E; Other.E; else Other.E; accept E do ... end E; end if; end T; I think the OP's problem is that he's trying to think about Ada tasking in terms of message passing. Ada tasks operate with rendezvous and protected objects, which are synchronous by default, rather than with message passing as in Erlang, which is asynchronous by default. -- Jeff Carter "Your mother was a hamster and your father smelt of elderberries." Monty Python & the Holy Grail 06