comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Distributed programming
Date: Sat, 05 Jul 2008 03:22:09 GMT
Date: 2008-07-05T03:22:09+00:00	[thread overview]
Message-ID: <BNBbk.95597$102.11071@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: g4isvd$mf6$1@registered.motzarella.org

In GNAT Ada package. the Remote_Call_Interface work but the and 
System.RPC (remote procedure calls) are basically dummy routines, see 
System.RPC ("s-rpc.adb"). The System.RPC active routines are in the 
GLADE and other packages. GLADE for one has some examples that you 
might be able to adapt to use needs.

Note: GLADE can be use for Ada-95, but Adacore decided to replace GLADE 
with the PolyORB package (by PolyORB) for "Ada 2005" and later.

Note: Most people just use networking instead, since it common to most 
OS and is widely used in all languages. You can find simple networking 
examples in Ada, C, COBOL, FORTRAN, Java, Pascal, etc on the net. 

Plus: A set of Tasking partitions with conditional "Accept" statement can 
simulate the System.RPC and Remote_Call_Interface. This way you can still 
use the protocols of Annex E without getting into the limitation (rules of 
Annex E) using the routines in the System.RPC.

Once you learn the basics then you can try adding the features of the 
Annex E.

As for Annex E being buggy.  It is difficult, initially to use but it 
does work quite efficient when used.


As for an example that meet the RM Annex E (from GLADE package).

------------------------------
-- pure.ads
--
package Pure is

   pragma Pure;

   N_Counts : constant := 10;
   N_Robots : constant := 10;

   type Message_Type is
      record
         Value : Integer;
         Count : Integer  := 0;
      end record;

end Pure;

------------------------------
-- rci.ads
--
package RCI is

   pragma Remote_Call_Interface;

   procedure Start (P : Natural);

end RCI;

------------------------------
-- rci.ads
--
with Ada.Text_IO;          use Ada.Text_IO;
with System.RPC;           use System.RPC;
with System.RPC.Stream_IO; use System.RPC.Stream_IO;
with Pure;                 use Pure;

package body RCI is

   task type Robot_Type is
      entry Start (I : Natural);
   end Robot_Type;

   task body Robot_Type is
      M : Message_Type;
      P : Natural;
      S : aliased Partition_Stream_Type;
   begin
      accept Start (I : Natural) do
         P := I;
      end Start;
      Ada.Text_IO.Put_Line ("Listen to" & P'Img);
      while M.Count < N_Counts loop
         Open (S, Any_Partition, In_Mode);
         Message_Type'Read  (S'Access, M);
         Ada.Text_IO.Put_Line ("Received message" & M.Value'Img &
                               " with count" & M.Count'Img);
         Close (S);
         M.Count := M.Count + 1;
         Open (S, Partition_ID (P), Out_Mode);
         Message_Type'Write (S'Access, M);
         Close (S);
      end loop;
   end Robot_Type;

   Robots : array (1 .. N_Robots) of Robot_Type;

   procedure Start (P : Natural) is
   begin
      for N in Robots'Range loop
         Robots (N).Start (P);
      end loop;
   end Start;

end RCI;

------------------------------
-- Main.adb
--
with RCI;                  use RCI;
with System.RPC;           use System.RPC;
with System.RPC.Stream_IO; use System.RPC.Stream_IO;
with Ada.Streams;          use Ada.Streams;
with Ada.Text_IO;          use Ada.Text_IO;
with Pure;                 use Pure;

procedure Main is

   task type Robot_Type is
      entry Start (I : Integer);
   end Robot_Type;

   task body Robot_Type is
      M : Message_Type;
      S : aliased Partition_Stream_Type;
   begin
      accept Start (I : Integer) do
         Put_Line ("Start robot" & I'Img);
         M.Value := I;
      end Start;
      while M.Count < N_Counts loop
         Open (S, RCI'Partition_ID, Out_Mode);
         Message_Type'Write (S'Access, M);
         Put_Line ("Send message" & M.Value'Img &
                   " with count" & M.Count'Img);
         Close (S);
         Open (S, RCI'Partition_ID, In_Mode);
         Message_Type'Read  (S'Access, M);
         Close (S);
      end loop;
   end Robot_Type;

   Robots : array (1 .. N_Robots) of Robot_Type;

begin
   RCI.Start (Main'Partition_ID);
   for N in Robots'Range loop
      Robots (N).Start (N);
   end loop;
end Main;




In <g4isvd$mf6$1@registered.motzarella.org>, =?ISO-8859-1?Q?S=E9bastien_Morand?= <seb.morand@gmail.com> writes:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Hi,
>
>I'm trying to get working the annex E of Ada about Distributed
>programming. I get very few pieces of information about it.
>
>Is there any body out there able to give me some tips how to use
>disttribuated programming?
>
>I know there is some pragma: Remove_Call_Interface for example, but I
>don't know how to get them working.
>
>Thanks by advance,
>
>Sebastien
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.5 (Cygwin)
>
>iD8DBQFIbPcr+zV9xm4PlDQRAlV5AJ9pzIWO6+xda2voqWrgpx2Ce4QapwCdGbnr
>oavwffeM8rb0I1GeeLpkZ/0=
>=LmgZ
>-----END PGP SIGNATURE-----




      parent reply	other threads:[~2008-07-05  3:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-03 15:58 Distributed programming Sébastien Morand
2008-07-04  9:09 ` Ken Thomas
2008-07-04  9:20   ` Ken Thomas
2008-07-04  9:44     ` Sébastien Morand
2008-07-04  9:40 ` xavier grave
2008-07-05  3:22 ` anon [this message]
replies disabled

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