comp.lang.ada
 help / color / mirror / Atom feed
From: "Frank" <franjoe@frisurf.no>
Subject: Re: Simple Producer/Consumer with Annex E
Date: Tue, 26 Jun 2001 22:45:58 +0200
Date: 2001-06-26T22:45:58+02:00	[thread overview]
Message-ID: <9x6_6.310$tD1.24698@news3.oke.nextra.no> (raw)
In-Reply-To: ScOX6.2872$_96.122872@news3.oke.nextra.no

Hi! (sorry if this is posted many times :-| , problems with attachment of
files)

Mike Nowak and I have had the following e-mails (added to this posting)
regarding my issue Subject: "Simple Producer/Consumer with Annex E" on
19.jun-2001 in this newsgroup.

It seems to us that the files that are added here
works for Mike Nowak and not for me. Nowak has rewritten my example slightly
(as described in the emails), he has not added a Makefile, but use mine as
the source code of the original problem is added to this email also.

He has a RedHat 6.0 and I have RedHat 6.2 (versions og gnat's speciefied in
emails)
Could anyone try this source code on other configurations of Ada?
(Unless you see the problem of course :-)

Frank

-----------------------------------
Mail 1:(Mike Nowaks first mail)
>Hi!
>
>I'm trying to create two "main" like procedures, one in each partition.
>These two procedures shall communicate with a task in a package placed in a
>third partition.
>In a third partition I place a package that contains a task (called
SERVER).
>This server
>initialize a buffer variable CURRENT_VALUE to 1000.

Sorry for long lack of response, but I have exam session, work, lab
projects.
I hope you solved this problem, but if no, maybe this can be some help.
I'm also totally new to Ada (just two projects), but during vacation I want
to seriously get into it.

I compiled your sources and all went OK. I removed option 'gtkada-option'
from Makefile, because I don't have GtkAda installed (does this really
come from GtkAda?). Receiver is dropping fast all messages, so all I saw
was (1000...1000....1000...124...124...124). I put delays into Sender and
Receiver and saw 1000...1000...123...123...124...124...and so on.
I'm using gnat 3.12p on RedHat Lnux 6.0
Try with sources from attachment, try remove 'gtkada-option'.
For me tha code look OK, (but as I said, I'n newbie), so I'm wonder
if it will work on your environment. (Sorry, I replaced SEND with PUT
because I got a little confused, lack of sleep maybe)

Good luck

--------------------------
Mike Nowak
mailto: vinnie@inetia.pl
----------------------------------------------------------------------------
-----------------------------

Mail 2: (my response):
Hi!

I'm grateful for your test.
I unzipped your files and took my own Makefile and removed the
gtkada-option.
You are right, the gtkada has nothing to do with the distributed solution,
however, it is my intention to put some GUI on top of my partitions when I
get through
these kind of obstacles :-)

Sadly, your suggestion did not make any difference for me, I still had the
same problem, both with your version and my own.

> I'm using gnat 3.12p on RedHat Lnux 6.0
I'm using
gnat-3.13p-runtime-1-5
gnat-3.13p-1-5
gnat-glade3.13p-1-5
on Red Hat 6.2 (Kernel 2.2.14-5.0 i686)
Have you done some configuration on your Unix that might affect sockets/ipc
or similar?

Do you mind if I add these e-mails to the thread in comp.lang.ada so we can
get reactions from the audience in there?

Frank

----------------------------------------------------------------------------
-----------------------------

Mail 3: (Mike Nowaks second mail).
Welcome back!

>Sadly, your suggestion did not make any difference for me, I still had the
>same problem,
>both with your version and my own.
>I'm using
>gnat-3.13p-runtime-1-5
>gnat-3.13p-1-5
>gnat-glade3.13p-1-5
>on Red Hat 6.2 (Kernel 2.2.14-5.0 i686)
>Have you done some configuration on your Unix that might affect sockets/ipc
>or similar?

Really sorry to hear that. I have no idea what can cause this problem and it
is
now hard for me to solve it, because it worked on my machine...
Lookslike it is not a source code problem. I did no change to my systems'
starting  configuration, it is nearly the same as on install time.
About three month ago I installed MPI library (for concurrent computing,
I had laboratory project in it), and there was a note for RedHat 6.2 users.
There was special instllation proces required and I'm not sure, maybe it
concerned sockets. I cannot find this document now (I deinstalled MPI and
borrow my friend CD with it), but when I get it back, I will check. I hope
your problem will be solved by this time.

>Do you mind if I add these e-mails to the thread in comp.lang.ada so we can
>get
>reactions from the audience in there?

Yes, do it freely. I did not sen answer to group, because of attachment, and
I wasnt's sure if passing attachments is turned on. Today I saw somebody did
it,
so it works. I hope somebody will answer, although, as I remember, no one
passed an aswer to group by today :((. There is lot of professional Ada
programmers there, it is a bit strange, that nobody answered. It wolud be
good,
if somebody test the program on the same configuration as yours.

Good luck!
-Mike
----------------------------------------------------------------------------
-----------------------------

 -------------------------------------
 Makefile
 all:
  gnatdist -v sender_server_receiver.cfg
 clean:
  rm -rf *.o *.ali dsa


--------------------------------------------------------------------------
with PA_SERVER;
with TEXT_IO;
procedure P_RECEIVER is
  RECEIVED : INTEGER;

begin
  PA_SERVER.START_SERVER;
  TEXT_IO.PUT_LINE ("Server has been started");
  loop
    PA_SERVER.RECEIVE (RECEIVED);
    TEXT_IO.PUT_LINE ("Received = " & RECEIVED'Img);
    Delay(0.5);
  end loop;

end P_RECEIVER;
--------------------------------------------------------------------------
with PA_SERVER;
with TEXT_IO;
procedure P_SENDER is

begin

  PA_SERVER.PUT (123);
  Delay(2.0);
  PA_SERVER.PUT (124);

end P_SENDER;
--------------------------------------------------------------------------
with TEXT_IO; use TEXT_IO;
package body PA_SERVER is

  task type TYPE_TASK_SERVER is

    entry START_SERVER;

    entry RECEIVE ( P_RECEIVE : out INTEGER);
    entry PUT ( P_SEND : in INTEGER);

  end TYPE_TASK_SERVER;

  task body TYPE_TASK_SERVER is
    RUNNING : BOOLEAN := FALSE;

    CURRENT_VALUE : INTEGER;

  begin

    CURRENT_VALUE := 1000;


    accept START_SERVER do
      RUNNING := TRUE;

    end START_SERVER;

    while RUNNING loop
      select
       accept RECEIVE (P_RECEIVE : out INTEGER) do
          P_RECEIVE := CURRENT_VALUE;
        end RECEIVE;

      or
        accept PUT (P_SEND : in INTEGER) do
          CURRENT_VALUE := P_SEND;
          Put_Line("Value in task: " & CURRENT_VALUE'Img);
        end PUT;

      end select;


    end loop;

  end TYPE_TASK_SERVER;

  SERVER : TYPE_TASK_SERVER;

  procedure RECEIVE (P_RECEIVE : out INTEGER)
  is
  begin
    SERVER.RECEIVE (P_RECEIVE);

  end RECEIVE;

  procedure PUT (P_SEND : in INTEGER)  is
  begin
    Put_Line("Value in procedure: " & P_SEND'Img);
    SERVER.PUT (P_SEND);
  end PUT;

  procedure START_SERVER is
  begin
    SERVER.START_SERVER;
  end START_SERVER;

end PA_SERVER;
--------------------------------------------------------------------------
package PA_SERVER is
  pragma Remote_Call_Interface;

  procedure RECEIVE (P_RECEIVE : out INTEGER);


  procedure PUT (P_SEND : in INTEGER);

  procedure START_SERVER;

end PA_SERVER;
--------------------------------------------------------------------------
configuration SENDER_SERVER_RECEIVER is

     PART_RECEIVER : Partition := (P_RECEIVER);
     for PART_RECEIVER'Host use "localhost";
     procedure P_RECEIVER is in PART_RECEIVER;


     PART_SENDER : Partition := (P_SENDER);
     for PART_SENDER'Host use "localhost";
     procedure P_SENDER;
     for PART_SENDER'Main use P_SENDER;

     PART_SERVER : Partition := (PA_SERVER);
     for PART_SERVER'Host use "localhost";

     pragma Starter (None);

end SENDER_SERVER_RECEIVER;

-------------
Franks first posting  to comp.lang.ada regarding this issue:


Frank <franjoe@frisurf.no> wrote in message
news:ScOX6.2872$_96.122872@news3.oke.nextra.no...
> Hi!
>
> I'm trying to create two "main" like procedures, one in each partition.
> These two procedures shall communicate with a task in a package placed in
a
> third partition.
> In a third partition I place a package that contains a task (called
SERVER).
> This server
> initialize a buffer variable CURRENT_VALUE to 1000.
>
> One of the procedures (P_SENDER) shall send two values to the server, and
> change the CURRENT_VALUE.
> The other procedure (P_RECEIVER) shall get the CURRENT_VALUE in the task.
> The receiver has a loop that prints the value it get from the server, this
> in order to see the progress.
> As the code is now, I start the server (executable get the name:
> PART_SERVER) first, and then I start the receiver (executable get the
name:
> PART_RECEIVER). The receiver starts printing 1000...1000...
> Then I start the sender (executable get the name: PART_SENDER).
>
> What I experience is that only the first of the values (123) I wish to
send
> is received at the receiver, and the next value is never passed.
>
> In the configuration file; I have established the P_RECEIVER procedure as
> the applications main procedure (which is placed in PART_RECEIVER), then I
> have established P_SENDER as a 'Main for partition PART_SENDER.
> I have done some experiments with this code, and have a hunch that it is
the
> sender that for some reason dosn't send the next value.
>
> I wonder if this is caused by the "for PART_SENDER'Main use P_SENDER"
> construction, that might not work as a believe?
> I believed that the 'Main construction would give me another "main", in
the
> sense that if I switched the roles of the to (P_RECEIVER and P_SENDER)
that
> should give me the same functionality. Is this nonsense?
>
> I have also considered the 'Task_Pool setting, but haven't quite succeded
in
> setting it. Does the compiler use some default values that gives me this
> situation?
>
> Does anyone have any suggestions?
>
> (Makefile, P_SENDER, P_RECEIVER and PA_SERVER is added to this posting)
>
> Frank
>
>
> -----------------------------------------
> configuration SENDER_SERVER_RECEIVER is
>
>      PART_RECEIVER : Partition := (P_RECEIVER);
>      for PART_RECEIVER'Host use "localhost";
>      procedure P_RECEIVER is in PART_RECEIVER;
>
>
>      PART_SENDER : Partition := (P_SENDER);
>      for PART_SENDER'Host use "localhost";
>      procedure P_SENDER;
>      for PART_SENDER'Main use P_SENDER;
>
>      PART_SERVER : Partition := (PA_SERVER);
>      for PART_SERVER'Host use "localhost";
>
>      pragma Starter (None);
>
> end SENDER_SERVER_RECEIVER;
> -----------------------------------------
> with PA_SERVER;
> with TEXT_IO;
> procedure P_SENDER is
>
> begin
>
>   PA_SERVER.SEND (123);
>   PA_SERVER.SEND (124);
>
> end P_SENDER;
> -----------------------------------------
> with PA_SERVER;
> with TEXT_IO;
> procedure P_RECEIVER is
>   RECEIVED : INTEGER;
>
> begin
>   PA_SERVER.START_SERVER;
>   TEXT_IO.PUT_LINE ("Server has been started");
>   loop
>     PA_SERVER.RECEIVE (RECEIVED);
>     TEXT_IO.PUT_LINE ("Received = " & RECEIVED'Img);
>   end loop;
>
> end P_RECEIVER;
> -----------------------------------------
> with TEXT_IO;
> package body PA_SERVER is
>
>   task type TYPE_TASK_SERVER is
>
>     entry START_SERVER;
>
>     entry RECEIVE ( P_RECEIVE : out INTEGER);
>     entry SEND ( P_SEND : in INTEGER);
>
>   end TYPE_TASK_SERVER;
>
>   task body TYPE_TASK_SERVER is
>     RUNNING : BOOLEAN := FALSE;
>
>     CURRENT_VALUE : INTEGER;
>
>   begin
>
>     CURRENT_VALUE := 1000;
>
>
>     accept START_SERVER do
>       RUNNING := TRUE;
>
>     end START_SERVER;
>
>     while RUNNING loop
>       select
>        accept RECEIVE (P_RECEIVE : out INTEGER) do
>           P_RECEIVE := CURRENT_VALUE;
>
>         end RECEIVE;
>
>       or
>         accept SEND (P_SEND : in INTEGER) do
>           CURRENT_VALUE := P_SEND;
>
>         end SEND;
>
>       end select;
>
>
>     end loop;
>
>   end TYPE_TASK_SERVER;
>
>   SERVER : TYPE_TASK_SERVER;
>
>   procedure RECEIVE (P_RECEIVE : out INTEGER)
>   is
>   begin
>     SERVER.RECEIVE (P_RECEIVE);
>
>   end RECEIVE;
>
>   procedure SEND (P_SEND : in INTEGER)  is
>   begin
>     SERVER.SEND (P_SEND);
>   end SEND;
>
>   procedure START_SERVER is
>   begin
>     SERVER.START_SERVER;
>   end START_SERVER;
>
> end PA_SERVER;
> -------------------------------------
> package PA_SERVER is
>   pragma Remote_Call_Interface;
>
>   procedure RECEIVE (P_RECEIVE : out INTEGER);
>
>
>   procedure SEND (P_SEND : in INTEGER);
>
>   procedure START_SERVER;
>
> end PA_SERVER;
>
> -------------------------------------
> Makefile
> all:
>  gnatdist -v sender_server_receiver.cfg `gtkada-config`
>
> clean:
>  rm -rf *.o *.ali dsa
>
>
>
>





  reply	other threads:[~2001-06-26 20:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-19 20:00 Simple Producer/Consumer with Annex E Frank
2001-06-26 20:45 ` Frank [this message]
2001-06-27  5:06   ` Wilhelm Spickermann
2001-06-28  7:07     ` Frank
     [not found] <E15F7Ws-00038J-00@beatrice.spick.nowhdus>
2001-07-03 17:02 ` Michal Nowak
2001-07-07  9:13   ` Frank
2001-07-10  7:52     ` Frank
2001-07-10 12:02       ` Wilhelm Spickermann
2001-07-10 15:04         ` Frank
2001-07-15 12:45           ` Michal Nowak
2001-07-16 17:26             ` Ted Dennison
2001-07-16 21:16               ` David C. Hoos
2001-07-16 21:41                 ` Ted Dennison
     [not found]               ` <094701c10e3c$917512c0$453ab4d8@sy.com>
2001-07-17 18:33                 ` Michal Nowak
     [not found] <E15JwDj-00077I-00@beatrice.spick.nowhdus>
2001-07-11 17:27 ` Michal Nowak
     [not found] <200107111927240390.00071225@smtp-po.inetia.pl>
2001-07-11 18:26 ` Wilhelm Spickermann
     [not found] <E15KOgZ-0001Jc-00@beatrice.spick.nowhdus>
2001-07-11 20:13 ` Michal Nowak
replies disabled

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