comp.lang.ada
 help / color / mirror / Atom feed
* Re: HELP! HELP!  Dynamic InterTask Communication between different Pac
@ 1991-11-14  3:13 Michael Feldman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Feldman @ 1991-11-14  3:13 UTC (permalink / raw)


In article <13NOV199116031506@elroy.uh.edu> cosc143u@elroy.uh.edu (91F9774) wri
tes:
 [ stuff deleted ]

>I know this is possible in Ada, but so far, no luck.  What is wrong with my
>approach (example code follows).  Thanks in advance for any help.
>.
>package t is
>    task type taskt is
>	entry callt;
>    end taskt;
>end package t;
>package body t is
>    task type taskt is
>    begin
>       accept callt;
>       taskp.callp;
>    end taskt;
>end t;
> .
>package p is
>    task type taskp is
>	entry callp;
>    end taskp;
>end package p;
>package body p is
>    task type taskp is
>    begin
>       accept callp;
>       taskt.callt;
>    end taskp;
>end p;
>
You're on the right track. You just need to get the compilation order
right. Add to package body (NOT spec) p the line
  with t;
and to the package body t the line
  with p;
then compile in the following order:
  spec of t
  spec of p
  body of t
  body of p

also the entry calls need to be qualified with the package names, e.g.
  t.taskt.callt
(or you can use a USE clause to get the same effect, if you don't
mind USEs).

You'll also need a main program that with's both packages, even if it's
a begin-null-end main (you need something to cause the packages to
be elaborated, in order to activate the tasks).

Write back by personal mail if you have more questions. Good luck.

Mike

-------------------------------------------------------------------------------
Michael B. Feldman
Visiting Professor 1991-92               Professor
Dept. of Comp. Sci. and Engrg.           Dept. of Elect. Engrg. and Comp. Sci.
University of Washington FR-35           The George Washington University
Seattle, WA 98105                        Washington, DC 20052

mfeldman@cs.washington.edu               mfeldman@seas.gwu.edu
(206) 632-3794 (voice)                   (202) 994-5253 (voice)
(206) 543-2969 (fax)                     (202) 994-5296 (fax)
-------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: HELP! HELP!  Dynamic InterTask Communication between different Pac
@ 1991-11-15 17:19 nuchat!shell!spjerint!jon
  0 siblings, 0 replies; 2+ messages in thread
From: nuchat!shell!spjerint!jon @ 1991-11-15 17:19 UTC (permalink / raw)


>I need to get two tasks in two different packages to communicat with each othe
r
>the problem is that it looks like it is impossible for both tasks to know abou
t
>each other unless they are in the same package.  In C I would just make up a 
>header file with forward references to both tasks just to define what they wer
e.

Well, in Ada, you do the same thing.  Only with package specs instead of
header files.

>I know this is possible in Ada, but so far, no luck.  What is wrong with my
>approach (example code follows).  Thanks in advance for any help.
>.

In one file, put this stuff
>package t is
>    task type taskt is
>	entry callt;
>    end taskt;
>end package t;

in another, put this guy, with the added lines
with p;
use p;
>package body t is
>    task type taskt is
>    begin
>       accept callt;
>       taskp.callp;
>    end taskt;
>end t;
> .

File 3 is this
>package p is
>    task type taskp is
>	entry callp;
>    end taskp;
>end package p;

File 4 is this, with added lines
with t;
use t;
>package body p is
>    task type taskp is
>    begin
>       accept callp;
>       taskt.callt;
>    end taskp;
>end p;

Then, compile the two specs first, then the two bodies.  Should
work fine.  I take it you've really got something more interesting
going on than your example shows.  Otherwise, this code doesn't 
go anywhere, since both tasks are waiting on a call from the other 
one.

Jon Holdman, jon@shell.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1991-11-15 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-11-14  3:13 HELP! HELP! Dynamic InterTask Communication between different Pac Michael Feldman
  -- strict thread matches above, loose matches on Subject: below --
1991-11-15 17:19 nuchat!shell!spjerint!jon

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