comp.lang.ada
 help / color / mirror / Atom feed
* Re: General task pointers, messages
@ 1992-04-08 22:02 Robert I. Eachus
  0 siblings, 0 replies; only message in thread
From: Robert I. Eachus @ 1992-04-08 22:02 UTC (permalink / raw)


In article <1992Apr3.230532.6704@mack.uit.no> roarf@stud.cs.uit.no (Roar Foshau
g) writes:

   I have two questions concerning tasks and synchronization of tasks. I 
   work on parallell simulation in Ada, and need Ada tasks to communicate
   in a two-way fashion...

   The usual way to do this in Ada is to use two calls and have the
task structure such that the return message always goes to the "right"
task:

      task X is				task Y is
      ...				  entry Request_Service(...);
      end X;				  entry Return_Status(...);
					end Y;

      task body X is			task body Y is
      begin				begin
        Y.Request_Service(...);		  loop
        ...				    accept Request_Service(...);
        Y.Return_Status(...);		    ...
	...				    accept Return_Status(...);
      end X;				  end loop;
					end Y;

     Note that X can use a conditional entry call on Return_Status to
avoid waiting on Y, but task Y can be tied up waiting for X to get its
status.  To avoid this problem you can use entry families to allow Y
to serve multiple requests, however the code gets messy so I won't
include it here.  (Declare Return_Status as an entry family, and pass
the index as an out parameter of the call to Request_Service.)


   The other question is whether it is possible to send asynchronous
   messages between tasks?  I would like a task to be able to tell
   another task something without blocking...

    There is a way to do it using pragma SHARED.  If you want to send
more than a word of data it is technically erroneous although most Ada
implementations implement it correctly.  However, if you are using
multiple processors with caches, you may have to explicitly code a
cache flush operation.

--

					Robert I. Eachus

with STANDARD_DISCLAIMER;
use  STANDARD_DISCLAIMER;
function MESSAGE (TEXT: in CLEVER_IDEAS) return BETTER_IDEAS is...

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1992-04-08 22:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-04-08 22:02 General task pointers, messages Robert I. Eachus

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