comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: confusion about message passing between the tasks
Date: Sat, 25 Oct 2014 10:54:11 -0700
Date: 2014-10-25T10:54:11-07:00	[thread overview]
Message-ID: <m2go3u$ors$2@dont-email.me> (raw)
In-Reply-To: <s9mn4alvqkbtu6kfhqphc3im4akn69641v@4ax.com>

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


  reply	other threads:[~2014-10-25 17:54 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24 16:44 confusion about message passing between the tasks compguy45
2014-10-24 18:39 ` Ludovic Brenta
2014-10-25  1:51   ` compguy45
2014-10-25  7:13     ` Ludovic Brenta
2014-10-24 23:49 ` Stribor40
2014-10-25  7:03   ` Ludovic Brenta
2014-10-25  7:58 ` Simon Wright
2014-10-25 13:01   ` compguy45
2014-10-25 14:11     ` Simon Wright
2014-10-25 17:25 ` Dennis Lee Bieber
2014-10-25 17:54   ` Jeffrey Carter [this message]
2014-10-25 22:23     ` Robert A Duff
2014-10-25 23:26       ` compguy45
2014-10-26  4:50         ` Dennis Lee Bieber
2014-10-26 10:20         ` Georg Bauhaus
2014-10-26  5:37       ` J-P. Rosen
2014-10-26  8:14         ` Pascal Obry
2014-10-26 15:47           ` J-P. Rosen
2014-10-26 20:27         ` Robert A Duff
2014-10-26 20:31           ` Robert A Duff
2014-10-26 20:36             ` Jeffrey Carter
2014-10-26 22:27               ` Robert A Duff
2014-10-26 23:23                 ` Jeffrey Carter
2014-10-27  0:46                   ` Robert A Duff
2014-10-27  2:18                     ` Jeffrey Carter
2014-10-27  7:51                     ` J-P. Rosen
2014-10-27  7:44             ` J-P. Rosen
2014-10-26 20:42           ` Dmitry A. Kazakov
2014-10-26 21:15             ` Brad Moore
2014-10-27  9:22               ` Dmitry A. Kazakov
2014-10-26 22:20             ` Robert A Duff
2014-10-27  7:40           ` J-P. Rosen
2014-10-25 23:42 ` compguy45
2014-10-25 23:55   ` compguy45
2014-10-26  0:24     ` Jeffrey Carter
2014-10-26  0:41       ` compguy45
2014-10-26 11:30         ` Brian Drummond
2014-10-26 15:40     ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox