comp.lang.ada
 help / color / mirror / Atom feed
From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject: Re: Simp,e example for 2 tasks
Date: Sun, 21 Sep 2014 11:59:46 -0400
Date: 2014-09-21T11:59:46-04:00	[thread overview]
Message-ID: <ljst1ahlc3oda0ahrjjsdq46bh5jnq7j9c@4ax.com> (raw)
In-Reply-To: 9b22dd09-6137-4f4b-8be1-28255032df70@googlegroups.com

On Sun, 21 Sep 2014 06:31:28 -0700 (PDT), Stribor40 <ikamzic@gmail.com>
declaimed the following:

>Would anyone be able to post simple example of ada program showing 2 tasks taking to each other please.  For example one task sends message to another saying "hi" and second taks replying "hi back". 
>I am having troubles finding example of simple program like this online

	Well... The problem domain is slightly under-specified.

	Ada doesn't "send message" in the way you may be thinking. It's more a
"pass a note during a handshake" (Rendezvous).

	The problem with your description is that of sequencing. A straight
linear interpretation is:

Task A										Task B
begin										begin
rendezvous with Task B					wait for rendezvous from any task
												end rendezvous
wait for rendezvous from any task			rendezvous with Task A
	end rendezvous
end											end

	There is nothing being passed there -- the rendezvous itself is the
"message". There is also no work being done inside the rendezvous. AND the
sequence is pretty much lock-step: B does nothing until A connects, then A
does nothing until B decides to connect to it.

	An alternative would be using an IN and OUT parameter on the rendezvous

begin										begin
rendezvous with B("Hello", reply)			wait for rendezvous(IN msg,
																OUT reply)
												reply = "Hello Back"
												end rendezvous
end											end

	Here there is only one rendezvous... one "handshake"; A does nothing
during the rendezvous until B ends the rendezvous after doing whatever it
wants (setting reply).

											
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/


  reply	other threads:[~2014-09-21 15:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-21 13:31 Simp,e example for 2 tasks Stribor40
2014-09-21 15:59 ` Dennis Lee Bieber [this message]
2014-09-21 16:03   ` Stribor40
2014-09-21 22:26     ` Dennis Lee Bieber
2014-09-21 16:09 ` Dmitry A. Kazakov
2014-09-21 16:28 ` Stribor40
2014-09-21 17:00 ` Brad Moore
2014-09-21 20:33   ` Jeffrey Carter
2014-09-22  7:18     ` Niklas Holsti
2014-09-22 17:48       ` Jeffrey Carter
2014-09-22 18:16         ` Niklas Holsti
2014-09-22 19:27           ` Dmitry A. Kazakov
replies disabled

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